Ich verwende urllib2 und urllib Bibliotheken in PythonWarum erhalte ich "HTTP-Fehler 405: Methode nicht erlaubt" beim Anfordern einer URL mit urllib2?
nehme ich hatte den folgenden Code
import urllib2
import urllib
url = 'http://ah.example.com'
half_url = u'/servlet/av/jd?ai=782&ji=2624743&sn=I'
req = urllib2.Request(url, half_url.encode('utf-8'))
response = urllib2.urlopen(req)
print response
wenn ich laufe den obigen Code Ich erhalte den folgenden Fehler
Traceback (most recent call last):
File "example.py", line 39, in <module>
response = urllib2.urlopen(req)
File "/usr/lib64/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib64/python2.7/urllib2.py", line 398, in open
response = meth(req, response)
File "/usr/lib64/python2.7/urllib2.py", line 511, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.7/urllib2.py", line 436, in error
return self._call_chain(*args)
File "/usr/lib64/python2.7/urllib2.py", line 370, in _call_chain
result = func(*args)
File "/usr/lib64/python2.7/urllib2.py", line 519, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 405: Method Not Allowed
kann jemand lassen Ich weiß, was hier passiert und warum es nicht funktioniert
Vielen Dank im Voraus ............
@ Paul: Vielen Dank für die Bearbeitung –