gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 11:36:31 25 4
gpt4 key购买 nike

我尝试像这样将 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com