程序运行后出现这个结果
def askURL(url):
head = { # 模拟头部信息
"User-Agent": "Mozilla / 5.0(Windows NT 10.0;Win64;x64) AppleWebKit / 537.36(KHTML, likeGecko) Chrome / 99.0.4844.74Safari / 537.36Edg / 99.0.1150.46",
"Host":"www.lagou.com",
"Accept":" text / html, application / xhtml + xml, application / xml;q = 0.9, image / webp, image / apng, * / *;q = 0.8, application / signed - exchange;v = b3;q = 0.9"
}
request = urllib.request.Request(url,headers=head)
html=""
try:
response= urllib.request.urlopen(request)
time.sleep(5)
html = response.read().decode("utf-8")
except urllib.error.URLError as e:
if hasattr(e,"code"):
print(e.code)
if hasattr(e,"reason"):
print(e.reason)
print(html)
return html