Problem mit POST-Request auf eine 302-Seite
Verfasst: Freitag 16. Dezember 2011, 14:56
Hallo Zusammen
Ich bin ein neuer in diesem Forum und auch in Python
Und hier schon mein ersten Problem:
Ich versuche in Python 3 einen POST-Request auf eine Seite zu machen, welche einen 302 Redirect im Header hat. Dabei erhalte ich immer einen Fehler.
Mein Code:
Dabei erhalte ich folgenden Fehler:
Der Request wird zwar abgesetzt, aber ich kann nicht mehr weitermachen aufgrund des HTTPError.
Weis jemand woran das liegen könnte?
Gruss
P3sch3
Ich bin ein neuer in diesem Forum und auch in Python
Und hier schon mein ersten Problem:
Ich versuche in Python 3 einen POST-Request auf eine Seite zu machen, welche einen 302 Redirect im Header hat. Dabei erhalte ich immer einen Fehler.
Mein Code:
Code: Alles auswählen
import urllib.request
import urllib.parse
value1 = 1
value2 = 2
params = urllib.parse.urlencode({"value1" : value1, "value2" : value2})
params = params.encode('utf-8')
f = urllib.request.urlopen("http://localhost/login.php", params)
Code: Alles auswählen
Traceback (most recent call last):
File "postreq2.py", line 13, in <module>
f = urllib.request.urlopen("http://localhost/login.php", param
s)
File "C:\Python32\lib\urllib\request.py", line 138, in urlopen
return opener.open(url, data, timeout)
File "C:\Python32\lib\urllib\request.py", line 375, in open
response = meth(req, response)
File "C:\Python32\lib\urllib\request.py", line 487, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python32\lib\urllib\request.py", line 407, in error
result = self._call_chain(*args)
File "C:\Python32\lib\urllib\request.py", line 347, in _call_chain
result = func(*args)
File "C:\Python32\lib\urllib\request.py", line 560, in http_error_302
headers, fp)
urllib.error.HTTPError: HTTP Error 302: Found - Redirection to url 'eingang.php' i
s not allowed
Weis jemand woran das liegen könnte?
Gruss
P3sch3