【发布时间】:2021-08-20 23:00:57
【问题描述】:
我想抓取一个站点,但我需要在站点中等待 30 秒才能获得我要查找的内容。
这就是我现在得到的:
import requests
url = 'https://sheldon.sdarot.tv/w/SD/480/57/153183/153183.mp4?token=Gfc7vmObqcRRjiJKSgwJnQ&time=1622659950&uid=457724'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0'}
proxies = {
'http': 'http://' + "185.169.198.98:3128",
'https': 'http://' + "185.169.198.98:3128",
}
s = requests.Session()
r = s.get(url, verify=True, headers=headers, proxies=proxies)
我该怎么做?
【问题讨论】:
-
time.sleep(30) -
您的用例可能更适合
selenium -
具体来说,请记住
requests只能将原始页面上的文本传递给您。如果您的浏览器中的页面发生更改,那是因为正在运行的 Javascript 代码正在更改页面。您没有运行 Javascript,因此无论您等待多长时间,您都不会看到这种变化。如果你需要 Javascript,那么你需要一个真正的浏览器,这就是selenium所做的。
标签: python python-requests keep-alive