我的目标是保存和加载响应以供以后使用。(可能是几天后)。我想要高效而不是随时抓取网站,而是将它们保存为文件并在需要时加载它们。
import requests
from bs4 import BeautifulSoup
html = requests.get(link, timeout=5)
page_content = BeautifulSoup(html.content, "html.parser")
"""" Example of function that I would like to load the responce here instead."""
def getValue(page):
return page.find('td', attrs={'class': 'Fz(s) Fw(500) Ta(end)'}).text
html类型:
<class 'requests.models.Response'>
page_content 的类型:
<class 'bs4.BeautifulSoup'>