我不确定它是否是我的计算机的设置(Windows 7,Python3.8,刚刚安装了 requests_html),但无论我选择哪个站点,该render
方法都导致timeout error
我玩弄了 timeout 参数,但没有运气.
import os
import sys
import requests_html
import requests
import pyppeteer
def get_request(url, render = False):
session = requests_html.HTMLSession()
res = session.get(url)
try:
res.raise_for_status()
except ValueError as e:
raise('Dead link')
if render:
res.html.render(sleep = 2, timeout = 20)
return res, session
def test_render():
url = 'https://www.yahoo.com/'
res, session = get_request(url, render = True)