Esempio n. 1
0
def test_speed(apply_to_siblings):
    tests = Path(__file__).parent
    html_1 = tests.joinpath('html-1.html').read_text()
    html_2 = tests.joinpath('html-2.html').read_text()
    n_runs = 1
    t0 = time.time()
    for _ in range(n_runs):
        # as_tree speed is almost the same, so don't bother to check
        extract_html_diff.as_string(html_1,
                                    html_2,
                                    apply_to_siblings=apply_to_siblings)
    print('as_string apply_to_siblings={} speed: {:.2f} pages/s'.format(
        apply_to_siblings, n_runs / (time.time() - t0)))
Esempio n. 2
0
def getTreePerformance(answer, predict):
    answer = answer.answer_dom
    predict = predict.predict_dom

    ted = extract_html_diff.as_string(answer, predict)

    tree_precision = (len(predict) - len(ted)) / len(predict)
    tree_recall = (len(answer) - len(ted)) / len(answer)
    tree_f1 = (2 * tree_precision * tree_recall) / \
              (tree_precision + tree_recall)

    return round(tree_precision, 3), round(tree_recall, 3), round(tree_f1, 3)
Esempio n. 3
0
        "*****@*****.**", "*****@*****.**",
        "*****@*****.**"
]:
    user = i

    # Using edge browser
    driver = webdriver.Edge(executable_path='msedgedriver')

    # Using Firefox browser
    # driver = webdriver.FirefoxProfile()
    # driver = webdriver.Firefox(driver)

    driver.get("https://quizlet.com/")
    element = driver.find_element_by_xpath(
        "//*[@id='TopNavigationReactTarget']/header/div/div[2]/div[3]/button[2]/span"
    )
    element.click()
    sleep(1)

    p1 = driver.page_source

    elem = driver.find_element_by_xpath("//input[@type='email']")
    elem.send_keys(user)
    elem.send_keys(Keys.TAB)
    sleep(2)

    p2 = driver.page_source
    p3 = extract_html_diff.as_string(p2, p1)
    if "It looks like" in p3:
        print(user)
    driver.close()
Esempio n. 4
0
def test_as_string():
    html = '<div> <h1>My site</h1> <div>My content</div> </div>'
    other_html = '<div> <h1>My site</h1> <div>Other content</div> </div>'
    assert extract_html_diff.as_string(html, other_html) == \
        '<div><div>My content</div> </div>'