urllib2.HTTPError: HTTP Error 405(Method Not Allowed)
2014-10-04 15:03
1796 查看
http server端要求GET方法,而请求的时候却使用了POST方法,因此出现了405错误
urllib2-GET方法
import urllib2,urllib,sys
url = "http://www.abc.com"
info = [('user','python'),('pass','python')]
getURL = url + "?" + urllib.urlencode(info)
request = urllib2.Request(getURL)
response = urllib2.urlopen(request)
>>> url="http://www.abc.com"
>>> search = [('user','python'),('pass','python')]
>>> getURL = url + "?" + urllib.urlencode(search)
>>> print getURL
http://www.abc.com?user=python&pass=python
urllib2-POST方法
url = "http://www.abc.com"
info = urllib.urlencode([('q','python')])
request = urllib2.Request(url,info)
response= urllib2.urlopen(request)
urllib2-GET方法
import urllib2,urllib,sys
url = "http://www.abc.com"
info = [('user','python'),('pass','python')]
getURL = url + "?" + urllib.urlencode(info)
request = urllib2.Request(getURL)
response = urllib2.urlopen(request)
>>> url="http://www.abc.com"
>>> search = [('user','python'),('pass','python')]
>>> getURL = url + "?" + urllib.urlencode(search)
>>> print getURL
http://www.abc.com?user=python&pass=python
urllib2-POST方法
url = "http://www.abc.com"
info = urllib.urlencode([('q','python')])
request = urllib2.Request(url,info)
response= urllib2.urlopen(request)
相关文章推荐
- Python报错“urllib2.HTTPError: HTTP Error 405: Not Allowed”的解决方法
- python网络请求报urllib2.HTTPError: HTTP Error 405: Not Allowed
- urllib2.HTTPError: HTTP Error 403: Forbidden
- urllib2.HTTPError: HTTP Error 504: Fiddler - Receive Failure
- urllib2.HTTPError: HTTP Error 403: Forbidden 分类: urllib2 2013-12-18 17:52 3886人阅读 评论(0) 收藏
- 使用wcf服务捕捉到“POST http://yourIP/WCFService.svc 405 (Method Not Allowed) ”错误!
- http请求 405错误 方法不被允许 (Method not allowed)
- 跨域调用web.py的restful接口报:OPTIONS https://... 405 (Method Not Allowed)
- HTTP 405 错误 – 方法不被允许 (Method not allowed)【转载】
- 【微信支付】分享一个失败的案例 跨域405(Method Not Allowed)问题 关于IM的一些思考与实践 基于WebSocketSharp 的IM 简单实现 【css3】旋转倒计时 【Html5】-- 塔台管制 H5情景意识 --飞机 谈谈转行
- urllib2.HTTPError: HTTP Error 403: Forbidden
- Py第十四问 urllib.error.HTTPError: HTTP Error 403: FORBIDDEN
- python urllib webbrowser HTTPError: HTTP Error 403: Forbidden
- python urllib2导出elasticsearch数据时 返回 "urllib2.HTTPError: HTTP Error 500: Internal Server Error"
- HTTP 405 错误 – 方法不被允许 (Method not allowed)
- HTTP 405 错误 – 方法不被允许 (Method not allowed)【转载】
- Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
- Method Not Allowed (#405) Method Not Allowed. This url can only handle the following request methods
- Python网页爬虫提示urllib2.HTTPError: HTTP Error 403: Forbidden 错误
- [Python] urllib2.HTTPError: HTTP Error 403: Forbidden