Seite 1 von 1
urllib2.urlopen("localhost"): ERROR
Verfasst: Freitag 6. November 2009, 15:18
von INFACT
Hi,
urllib2.urlopen weigert sich, meinen localhorst anzusprechen.
Code: Alles auswählen
>>> urlopen("127.0.0.1")
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
urlopen("127.0.0.1")
File "C:\Python26\lib\urllib2.py", line 124, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python26\lib\urllib2.py", line 381, in open
protocol = req.get_type()
File "C:\Python26\lib\urllib2.py", line 242, in get_type
raise ValueError, "unknown url type: %s" % self.__original
ValueError: unknown url type: 127.0.0.1
Was kann ich da machen?
Gibts eine andere möglichkeit oder einen workaround?
Verfasst: Freitag 6. November 2009, 15:33
von Leonidas
Schon mal versucht dass Protokoll davor zu setzen? Schließlich ist ``127.0.0.1`` ja nichtmal eine URL, da wärs ja etwas dreist zu erwarten dass urllib sowas kann.
Verfasst: Freitag 6. November 2009, 15:51
von INFACT
grrr...
Danke!
Das klappt, aber wenn ich jetzt noch ein port dazuhaben will
Bekomme ich diese Meldung:
Code: Alles auswählen
Traceback (most recent call last):
File "<pyshell#48>", line 1, in <module>
urlopen("http://localhost:8461")
File "C:\Python26\lib\urllib2.py", line 124, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python26\lib\urllib2.py", line 395, in open
response = meth(req, response)
File "C:\Python26\lib\urllib2.py", line 508, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python26\lib\urllib2.py", line 427, in error
result = self._call_chain(*args)
File "C:\Python26\lib\urllib2.py", line 367, in _call_chain
result = func(*args)
File "C:\Python26\lib\urllib2.py", line 603, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "C:\Python26\lib\urllib2.py", line 395, in open
response = meth(req, response)
File "C:\Python26\lib\urllib2.py", line 508, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python26\lib\urllib2.py", line 427, in error
result = self._call_chain(*args)
File "C:\Python26\lib\urllib2.py", line 367, in _call_chain
result = func(*args)
File "C:\Python26\lib\urllib2.py", line 603, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "C:\Python26\lib\urllib2.py", line 395, in open
response = meth(req, response)
File "C:\Python26\lib\urllib2.py", line 508, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python26\lib\urllib2.py", line 433, in error
return self._call_chain(*args)
File "C:\Python26\lib\urllib2.py", line 367, in _call_chain
result = func(*args)
File "C:\Python26\lib\urllib2.py", line 516, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 440:
Verfasst: Freitag 6. November 2009, 16:15
von Defnull
Auch das ist noch keine URL. Versuch "
http://localhost:8461/"
PS: Da sieht man mal, wie schädlich Fehler tolerante Software (Browser) is, wenn es um die Verbreitung von Standards und Konventionen geht

Verfasst: Freitag 6. November 2009, 16:17
von INFACT
Macht keinen unterschied
Defnull hat geschrieben:Auch das ist noch keine URL. Versuch "
http://localhost:8461/"
PS: Da sieht man mal, wie schädlich Fehler tolerante Software (Browser) is, wenn es um die Verbreitung von Standards und Konventionen geht

Ich gebe immer nur einzelne Wörter in den Browser: "python forum", "python clientform download" etc.
Verfasst: Freitag 6. November 2009, 17:55
von ms4py
Also bei mir funktioniert das:
Code: Alles auswählen
>>> urllib2.urlopen('http://localhost:8000/')
<addinfourl at 44852088 whose fp = <socket._fileobject object at 0x02AC3330>>
Liegt vermutlich an deinem Webserver! Was steckt denn dahinter?
Verfasst: Freitag 6. November 2009, 18:43
von nemomuk
localhost != 127.0.0.1 außer in der hosts-Datei angegeben.
Verfasst: Freitag 6. November 2009, 19:35
von apollo13
SchneiderWeisse hat geschrieben:localhost != 127.0.0.1 außer in der hosts-Datei angegeben.
selbst dann macht es je nach anwendung einen unterschied…
Verfasst: Samstag 7. November 2009, 00:51
von nemomuk
apollo13 hat geschrieben:SchneiderWeisse hat geschrieben:localhost != 127.0.0.1 außer in der hosts-Datei angegeben.
selbst dann macht es ja nach anwendung einen unterschied…
Wie meinen? Verstehe irgendwie den Satz nicht... ja=je?
Verfasst: Samstag 7. November 2009, 12:42
von apollo13
Sry, sollte natürlich je heißen, habs mal ausgebessert…