什么是缓存HTML网站并衡量使用它的时间收益的最佳库?

时间:2019-07-09 22:29:04

标签: html python-3.x caching

我正在寻找python 3中的库,它将本地存储的HTML站点放入缓存中。接下来,我需要衡量从缓存中加载它的好处(我使用time.time()和selenium来确保该页面已完全加载)。您能否通过推荐缓存管理器/库来帮助我,以简便的方式完成

我尝试过烧杯库,但是它不支持python3(仅2个)。

def openBrowser():
    start = time.time()
    browser = webdriver.Chrome()
    browser.get('<PATH TO LOCAL HTML FILE>')
    delay = 3
    try:
        myElem = WebDriverWait(browser, delay).until(EC.presence_of_element_located((By.ID, 'video')))
        print("Page is ready!")
        end = time.time()
    except TimeoutException:
        print("Loading took too much time!")
    result = end - start
    return result


def putToCacheAndOpen():
    start = time.time()
    browser = webdriver.Chrome()
    #### SOME CACHING######
    browser.get('<PATH TO LOCAL HTML FILE>')
    delay = 3
    try:
        myElem = WebDriverWait(browser, delay).until(EC.presence_of_element_located((By.ID, 'video')))
        print("Page is ready!")
        end = time.time()
    except TimeoutException:
        print("Loading took too much time!")
    result = end - start
    return result


print(openBrowser())
print(putToCacheAndOpen())
print("DONE")

0 个答案:

没有答案