use*_*715 5 python google-app-engine urllib2
尝试在google应用引擎中使用urllib2获取网址时出现以下错误:
error: An error occured while connecting to the server: Unable to fetch URL: http://www.google.com Error: [Errno 10106] getaddrinfo failed
Run Code Online (Sandbox Code Playgroud)
这是调用urllib2开放读取方法的代码:
def get(self):
self.write(urllib2.urlopen("http://www.google.com").read())
self.render_index()
Run Code Online (Sandbox Code Playgroud)
没什么好看的,只是调用主处理程序中的库来取出所提取的文本.
我的电脑正确解析了DNS.我可以使用python interpeter中的urllib2库,成功获取URL.
从谷歌服务器运行的部署代码按预期工作,这是我的本地环境,但我找不到它是什么.
我也尝试使用来自gae的urlfetch,结果相似(同样的getaddrinfo失败)
在使用urllib2库之前几天我切换到了Google DNS,但是切换回ISP提供的DNS也没有用.
编辑:当使用IP地址调用该函数时,将获取URL:
self.write(urllib2.urlopen("http://173.194.42.34").read())
Run Code Online (Sandbox Code Playgroud)
提前致谢!