---
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
''' import urllib.request url='https://www.baidu.com' resp=urllib.request.urlopen(url) ''' import urllib.request url='https://www.baidu.com' headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.100 Safari/537.36'} #构建请求对象 req=urllib.request.Request(url,headers=headers) #获取opener对象 opener=urllib.request.build_opener() resp=opener.open(req) print(resp.read().decode())
标签:urlopen,resp,request,urllib,url,3.4,opener,源代码 From: https://www.cnblogs.com/988MQ/p/17044986.html