方法一:
import urlib.request
url = ""
headers=("User-Agent","")
opener = urllib.request.build_opener()
opener.addheaders = [headers]
data=open(url).read()
方法二:
import urllib.request
url = ""
req=urllib.request.Request(url)
req.add_header('User-Agent', '')
data = urllib.request.urlopen(req).read()