Google app engine 谷歌应用程序引擎lxml生产错误
我在谷歌应用程序引擎上使用了lxml来获取一些基本数据 它可以与SDK配合使用。当我尝试在appengine服务器上使用它时,我得到了一个好消息Google app engine 谷歌应用程序引擎lxml生产错误,google-app-engine,lxml,Google App Engine,Lxml,我在谷歌应用程序引擎上使用了lxml来获取一些基本数据 它可以与SDK配合使用。当我尝试在appengine服务器上使用它时,我得到了一个好消息 IOError: Error reading file 'http://www.google.com': failed to load external entity "http://www.google.com" 我的代码看起来像 import lxml.html url = "http://www.google.com" t = lxml.htm
IOError: Error reading file 'http://www.google.com': failed to load external entity "http://www.google.com"
我的代码看起来像
import lxml.html
url = "http://www.google.com"
t = lxml.html.parse(url)
pagetitle = t.find.(".//title").text
self.response.out.write(pagetitle)
编辑:
我最后不得不做一个小的改变来处理,正如下面的答案所述
from google.appengine.api import urlfetch
result = urlfetch.fetch(url)
t = lxml.html.fromstring(result.content)
GAE不支持打开套接字,您应该使用
urlfetch.fetch()
获取页面内容,然后将其提供给解析器