将机械化模块导入python脚本 [英] import mechanize module to python script
问题描述
我尝试将机械化模块导入到我的python脚本中, 从机械化导入浏览器
但是,在访问我的脚本时,Google Appengine会抛出HTTP 500.
为了让事情更加清晰,让我给您看看我的包结构快照,
$ b
root
....机械化(其中所有机械化相关文件)
.... main.py
.... app.yaml
.... image
.... script
任何人都可以帮我解决这个问题吗?
谢谢,
Ponmalar
mechanize主页显示:
mechanize.Browser是机械化的一个子类。 UserAgentBase,它又是urllib2.OpenerDirector的一个子类。
我的理解是urllib2是GAE中的沙盒模块之一,其功能被Google提供的urlfetch取代。如果可能的话,您需要重新实施mechanize.UserAgentBase类以使用urlfetch。
I tried to import mechanize module to my python script like this,
from mechanize import Browser
But, Google appengine throws HTTP 500 when accessing my script.
To make things more clear, Let me give you the snapshot of my package structure,
root
....mechanize(where all the mechanize related files there)
....main.py
....app.yaml
....image
....script
Can anyone help me out to resolve this issue?
Thanks, Ponmalar
The mechanize main page says:
mechanize.Browser is a subclass of mechanize.UserAgentBase, which is, in turn, a subclass of urllib2.OpenerDirector
My understanding is that urllib2 is one of the sandboxed modules in GAE, with its functionality being replaced by the Google-provided urlfetch. You'd need to re-implement the mechanize.UserAgentBase class to use urlfetch, if that's at all possible.
这篇关于将机械化模块导入python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!