python - 将机械化模块导入 python 脚本

标签 python google-app-engine

我尝试像这样将 mechanize 模块导入到我的 python 脚本中,

from mechanize import Browser

但是,Google appengine 在访问我的脚本时抛出 HTTP 500。

为了让事情更清楚,让我给你我的包结构的快照,

root
 ....mechanize(where all the mechanize related files there)
 ....main.py
 ....app.yaml
 ....image
 ....script

谁能帮我解决这个问题?

谢谢, 波马拉尔

最佳答案

机械化主页说:

mechanize.Browser is a subclass of mechanize.UserAgentBase, which is, in turn, a subclass of urllib2.OpenerDirector

我的理解是 urllib2 是 GAE 中的沙盒模块之一,其功能已被 Google 提供的 urlfetch 取代。如果可能的话,您需要重新实现 mechanize.UserAgentBase 类才能使用 urlfetch。

关于python - 将机械化模块导入 python 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/275980/

相关文章:

node.js - 在 Google App Engine 中处理/_ah/start 路由 NodeJ

android - 使用 Android AccountManager 通过 UserService 做 AppEngine 登录

javascript - 如何使用 Flask 丑化 ES6 javascript?

python - 替换嵌套列表中某些列表中的值

python - 在python中从大量xml文件中提取信息的最有效方法是什么?

google-app-engine - datastore.Get 使用祖父 key

python - 从 pandas 数据帧创建边缘列表非常慢

python - -> 在 Python 函数定义中是什么意思?

python - 谷歌应用引擎 : Error in bulkloader. yaml

java - 在一对多关系中替换父级后删除孤儿