Wie man HTTP-Anforderung durch einen (tor -) socks-proxy mit python?
Ich bin versucht, einen HTTP-request mit python. Ich habe versucht, meine windows-system-proxy (mit inetcpl.cpl
)
url = 'http://www.whatismyip.com'
request = urllib2.Request(url)
request.add_header('Cache-Control','max-age=0')
request.set_proxy('127.0.0.1:9050', 'socks')
response = urllib2.urlopen(request)
response.read()
ist mir der Fehler
Traceback (most recent call last): File "", line 1, in
response = urllib2.urlopen(request) File "C:\Python27\lib\urllib2.py", line 126, in urlopen
zurück _opener.open(url, Daten, timeout) File "C:\Python27\lib\urllib2.py", line 400, in open
response = self._open(req, Daten) - Datei "C:\Python27\lib\urllib2.py" Linie 423, in _open
'unknown_open', req) File "C:\Python27\lib\urllib2.py", line 378, in _call_chain
Ergebnis = func(*args) File "C:\Python27\lib\urllib2.py", Linie 1240, in unknown_open
erhöhen URLError ("unknown url type: %s' % type) URLError:
InformationsquelleAutor der Frage claws | 2012-06-10
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ich bin der OP. Nach der Antwort von Tisho, dieser arbeitete für mich:
InformationsquelleAutor der Antwort claws
Scheint es URLLIB2 nicht unterstützt SOCKS als proxy-Typ(wie hier beschrieben: Wie kann ich einen SOCKS 4/5-proxy mit urllib2?). Blick auf http://code.google.com/p/socksipy-branch/ ein Beispiel für das urllib+Socken.
InformationsquelleAutor der Antwort Tisho