python 获取网页代码url为什么不能为ip?
、、、、、、、。url="http://220.181.111.86"#百度ippage=urllib.urlopen(url)html=page.read()print...
、、、、
、、、。
url="http://220.181.111.86" #百度ip
page=urllib.urlopen(url)
html=page.read()
print html
出错!
Traceback (most recent call last): File "C:\Users\su\Desktop\新建文件夹\my-pachong.py", line 33, in <module> html2=gethtml("http://220.181.111.86") File "C:\Users\su\Desktop\新建文件夹\my-pachong.py", line 6, in gethtml page=urllib.urlopen(url) File "C:\Python27\lib\urllib.py", line 87, in urlopen return opener.open(url) File "C:\Python27\lib\urllib.py", line 208, in open return getattr(self, name)(url) File "C:\Python27\lib\urllib.py", line 352, in open_http 'got a bad status line', None)IOError: ('http protocol error', 0, 'got a bad status line', None)>>> 展开
、、、。
url="http://220.181.111.86" #百度ip
page=urllib.urlopen(url)
html=page.read()
print html
出错!
Traceback (most recent call last): File "C:\Users\su\Desktop\新建文件夹\my-pachong.py", line 33, in <module> html2=gethtml("http://220.181.111.86") File "C:\Users\su\Desktop\新建文件夹\my-pachong.py", line 6, in gethtml page=urllib.urlopen(url) File "C:\Python27\lib\urllib.py", line 87, in urlopen return opener.open(url) File "C:\Python27\lib\urllib.py", line 208, in open return getattr(self, name)(url) File "C:\Python27\lib\urllib.py", line 352, in open_http 'got a bad status line', None)IOError: ('http protocol error', 0, 'got a bad status line', None)>>> 展开
2个回答
展开全部
你上面输入的这个IP,百度在IP访问上面做了HTTP302跳转,一切请求直接转发到www.baidu.com获取到的并不是IP地址是域名!你试试其他的IP看看比如BD的联通节点61.135.169.105
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询