为了账号安全,请及时绑定邮箱和手机立即绑定

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.com

E:\python code>

版本:PYTHON 2.7.5 for windows?

正在回答

1 回答

已解决

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Python开发简单爬虫
  • 参与学习       227670    人
  • 解答问题       1219    个

本教程带您解开python爬虫这门神奇技术的面纱

进入课程
意见反馈 帮助中心 APP下载
官方微信