This piece of python code should print out some information, but doesn't

Ext*_*eze 1 python

The code I'm tring to get should look something like this:

发送:'GET /xml/atom.xml HTTP/1.0\r \n主机:diveintomark.org\r \n用户代理:Python-urllib/1.17\r \n\r \n'回复:'HTTP/1.1 410 Gone\r \n'标题:日期:星期六,2010年9月11日11:47:19 GMT
标题:服务器:Apache
标题:Content-Length:307
标题:连接:关闭
标题:Content-Type:text/html; 字符集= 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()
Run Code Online (Sandbox Code Playgroud)

Wol*_*lph 5

我相信这个例子完全错了,试试这个:

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()
Run Code Online (Sandbox Code Playgroud)