python3代码:
import urllib
import urllib.request
req = urllib.request.Request(url)
req.add_header("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)")
response = urllib.request.urlopen(req)
print(response.getcode())
import urllib
import urllib.request
req = urllib.request.Request(url)
req.add_header("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)")
response = urllib.request.urlopen(req)
print(response.getcode())
2017-04-21