ich hätte da mal wieder einen Fehler.
Ich befasse mich momentan mit der urllib2, welche ich in verbindung mit BS zum parsen von HTML-Dokumenten benutze.
Bis jetzt hat alles ganz gut geklappt und ich habe tonnen von Dokumente geparst. Jetzt habe ich eine andere Quelle (anderer Link auf gleichen Webserver) angepasst und nach der dritten Seite bekomme ich einen Fehler aus der urllib2:
Code: Alles auswählen
self.html = urllib2.urlopen(req).read()
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 410, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 448, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 531, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request
Code: Alles auswählen
headers = { 'User-Agent' : 'Mozilla/5.0' }
req = urllib2.Request(url, None, headers)
self.html = urllib2.urlopen(req).read()
Was könnte hier falsch laufen?
Ich bedanke mich schon einmal im Voraus für eure Hilfe!