【问题标题】:What's wrong :lxml.html.parse in google app怎么了:谷歌应用程序中的lxml.html.parse
【发布时间】: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。

标签: python parsing lxml


【解决方案1】:

lxml是C模块,GAE只支持纯python模块所以不支持。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-16
    • 1970-01-01
    • 1970-01-01
    • 2010-09-13
    • 2017-12-25
    • 2023-03-21
    • 2022-12-07
    相关资源
    最近更新 更多