urllib, chain args fehler? [solved]
Verfasst: Freitag 28. Dezember 2007, 01:23
Hi
Ja ich schon wieder ^^
Ich hab ein kleines Script erstellt das Zeilen aus einer Datei liest und diese dann per urllib in einen Link fügt und aufruft.
Somit schreibt das Ding für mich
Das Problem ist aber, sobald eine Zeile ein Leerzeichen hat wie z.B. "Guten Tag" bekomm ich folgende Fehlermeldung (siehe unten).
Gibts da ne möglichkeit Python zu sagen das er das Leerzeichen ignoriren soll?
Im normalen Browser kappts ja auch.
Ja ich schon wieder ^^
Ich hab ein kleines Script erstellt das Zeilen aus einer Datei liest und diese dann per urllib in einen Link fügt und aufruft.
Somit schreibt das Ding für mich
Das Problem ist aber, sobald eine Zeile ein Leerzeichen hat wie z.B. "Guten Tag" bekomm ich folgende Fehlermeldung (siehe unten).
Gibts da ne möglichkeit Python zu sagen das er das Leerzeichen ignoriren soll?
Im normalen Browser kappts ja auch.
Traceback (most recent call last):
File "/home/angelus/Projekte/Python/v0.9.py", line 17, in <module>
import engine
File "/home/angelus/Projekte/Python/v0.9/engine.py", line 79, in <module>
text.reader(data[0], data[1], data[2])
File "/home/angelus/Projekte/Python/v0.9/text.py", line 42, in reader
response = urlopen(url).read()
File "/usr/lib64/python2.5/urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "/usr/lib64/python2.5/urllib2.py", line 380, in open
response = meth(req, response)
File "/usr/lib64/python2.5/urllib2.py", line 491, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.5/urllib2.py", line 418, in error
return self._call_chain(*args)
File "/usr/lib64/python2.5/urllib2.py", line 353, in _call_chain
result = func(*args)
File "/usr/lib64/python2.5/urllib2.py", line 499, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 400: Bad Request
Code: Alles auswählen
if start == 'Y' or start == 'y': i = 0 while i < loops: x = 0 while x < lines: read = openpath.readline() text = read[:-1] print text url = 'http://chat%s.fidion.de/schreibe.php?http_host=%s&id=%s&schreibe.php&text2=%s&aktion=Go!' % (chat, domain, sessionid, text) print url response = urlopen(url).read() print response time.sleep(timeout) x += 1 else: openpath.seek(0) i += 1 else: exiturl = urlopen(('http://chat%s.fidion.de/index.php?http_host=%s&id=%s&aktion=logoff') % (chat, domain, sessionid)).read() print 'File reading done!' else: print 'Have a nice day.'