提前感谢您的帮助!
我想获取网站的内容,因此我使用urllib.urlopen(url)
。
set url='http://localhost:8080'(tomcat page)
如果我使用Google App Engine Launcher,请运行该应用程序,浏览http://localhost:8082
,效果很好。
但是,如果我指定应用程序的地址和端口:
python `"D:\Program Files\Google\google_appengine\dev_appserver.py" -p 8082 -a 10.96.72.213 D:\pagedemon\videoareademo`
出了点问题:
Traceback (most recent call last):
File "D:\Program Files\Google\google_appengine\google\appengine\ext\webapp\_webapp25.py", line 701, in __call__
handler.get(*groups)
File "D:\pagedemon\videoareademo\home.py", line 76, in get
wp = urllib.urlopen(url)
File "C:\Python27\lib\urllib.py", line 84, in urlopen
return opener.open(url)
File "C:\Python27\lib\urllib.py", line 205, in open
return getattr(self, name)(url)
File "C:\Python27\lib\urllib.py", line 343, in open_http
errcode, errmsg, headers = h.getreply()
File "D:\Program Files\Google\google_appengine\google\appengine\dist\httplib.py", line 334, in getreply
response = self._conn.getresponse()
File "D:\Program Files\Google\google_appengine\google\appengine\dist\httplib.py", line 222, in getresponse
deadline=self.timeout)
File "D:\Program Files\Google\google_appengine\google\appengine\api\urlfetch.py", line 263, in fetch
return rpc.get_result()
File "D:\Program Files\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 592, in get_result
return self.__get_result_hook(self)
File "D:\Program Files\Google\google_appengine\google\appengine\api\urlfetch.py", line 365, in _get_fetch_result
raise DownloadError(str(err))
DownloadError: ApplicationError: 2 [Errno 11003] getaddrinfo failed
最奇怪的是,当我将网址格式“http://localhost:8080
”更改为“http://127.0.0.1:8080
”时,它运作良好!
我google了很多,但我没有找到任何好的解决方案。希望得到一些帮助! 另外,我没有配置任何 proxy.IE 效果很好。
答案 0 :(得分:1)
您的系统不一定知道localhost应解析为127.0.0.1。您可能需要在主机文件中添加一个条目。在Windows上,它位于C:\Windows\System32\drivers\etc\hosts