我正在寻找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")