【发布时间】:2012-01-21 08:54:09
【问题描述】:
这是我的 app.yaml:
application: helloworld
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.app
libraries:
- name: lxml
version: latest
这里是helloworld.py:
from google.appengine.api import urlfetch
import lxml.html
down = "http://sc.hkex.com.hk/gb/www.hkex.com.hk/chi/market/sec_tradinfo/stockcode/eisdeqty_c.htm"
file = urlfetch.fetch(down)
print file.content
root = lxml.html.parse(file.content)
data = root.xpath('//tr[@class="tr_normal"]/td[position()=1]')
name = [row.text_content() for row in data]
for code in name:
print code
当我跑步时:
google_appengine/dev_appserver.py helloworld/
我打开127.0.0.1:8080,我可以看到网站http://sc.hkex.com.hk/gb/www.hkex.com.hk/chi/market/sec_tradinfo/stockcode/eisdeqty_c.htm,但print file.content 行的输出错误。
你能告诉我如何解决这个问题吗?
【问题讨论】:
-
我认为 Lxml 甚至不会出现在 GAE。