在Python 3中,以下代码获取网页的HTML源代码。
import urllib.request
url = "https://docs.python.org/3.4/howto/urllib2.html"
response = urllib.request.urlopen(url)
response.read()
我可以翻译成以下内容:在使用urllib.request时,我该如何将以下自定义头部添加到请求中?
headers = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)' }