url错误
代码:
from urllib2 import *
request=Request("book.douban.com")
request.add_header("JK.","Internet Explorer/11")
response=urlopen(request)
value=read(response)
print value
错误消息:
E:\python code>C:/Python27/python.exe "e:/python code/somethingsnotaboutshape/scrapy.py"
Traceback (most recent call last):
File "e:/python code/somethingsnotaboutshape/scrapy.py", line 4, in <module>
response=urlopen(request)
File "C:\Python27\lib\urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 396, in open
protocol = req.get_type()
File "C:\Python27\lib\urllib2.py", line 258, in get_type
raise ValueError, "unknown url type: %s" % self.__original
ValueError: unknown url type: book.douban.comE:\python code>
版本:PYTHON 2.7.5 for windows?