我要获取的代码应该如下所示:
send: 'GET /xml/atom.xml HTTP/1.0\r\nHost: diveintomark.org\r\nUser-Agent: Python-urllib/1.17\r\n\r\n' reply: 'HTTP/1.1 410 Gone\r\n' header: Date: Sat, 11 Sep 2010 11:47:19 GMT
header: Server: Apache
header: Content-Length: 307
header: Connection: close
header: Content-Type: text/html; charset=iso-8859-1
我输入的代码无效。谁能告诉我它有什么问题:
import httplib, urllib2
httplib.HTTPConnection.debuglevel = 1
request = urllib2.Request('http://www.google.co.uk/')
opener = urllib2.build_opener()
feeddata = opener.open(request).read()
请您参考如下方法:
我认为这个例子是完全错误的,试试这个:
import urllib2
request = urllib2.Request('http://www.google.co.uk/')
http_handler = urllib2.HTTPHandler(debuglevel=1)
opener = urllib2.build_opener(http_handler)
feeddata = opener.open(request).read()
