我已经在我的电脑上安装了twill(之前安装了python2.5),并且最近一直在使用它。在
Python安装在我的计算机上的磁盘C上:C:\Python25
twill文件夹(“twill-0.9”)位于这里:E:\tmp\twill-0.9
下面是我在twill中使用的代码:
go “some website’s sign-in page URL”
formvalue 2 userid “my login”
formvalue 2 pass “my password”
submit
go “URL of some other page from that website”
save_html result.txt
这段代码帮助我登录到一个我有账户的网站,记录该网站其他页面的HTML代码(只有在登录后才能访问),并将其存储在一个名为结果.txt“(当然,在使用此代码之前,我首先需要将“我的登录名”替换为我的真实登录名,“我的密码”和我的真实密码,“某个网站的登录页面URL”和“该网站其他页面的URL”,其中包含该网站的真实URL,数字2为该网站上用作该网站登录页面登录表单的表单编号)
我储存的代码“测试.斜纹位于我的“twill-0.9”文件夹中的文件:E:\tmp\twill-0.9\测试.斜纹 我在命令提示符下运行这个文件:pythontwillsh测试.斜纹在
现在,我也安装了“谷歌应用引擎”中的“谷歌应用引擎SDK”,并且已经使用了一段时间。在
例如,我一直在使用以下代码:
^{pr2}$这段代码帮助我将短语“无人检查垃圾邮件重复”转换为md5摘要。在
现在,我如何将这两段代码组合成一个可以在“googleappengine”上运行的python脚本?在
比方说,我希望我的代码从“googleappengine”登录到一个网站,转到该网站的另一个页面,记录它的HTML代码(这是我的twill代码所做的),然后将这个HTML代码转换成md5摘要(这是我的第二个代码所做的)。那么,如何将这两个代码组合成一个python代码呢?在
我想,应该通过进口斜纹布来完成,但是怎么能做到呢?一个python代码——由“googleappengine”运行的代码——能从互联网上的某个地方导入twill吗?或者“谷歌引擎已经安装了”?在
更新1:
(这是我对伍布尔回答的回应)
这是包含__init
}\py文件的所有文件夹(在我的“twill-0.9”文件夹中)的列表。(此列表中的某些文件夹位于其他文件夹的内部,此列表中也提到了这些文件夹):
E:\twill-0.9\build\lib\twill\extensions\match\parse
E:\twill-0.9\build\lib\twill\extensions
E:\twill-0.9\build\lib\twill\other\u packages\\u mechanize_dist
E:\twill-0.9\build\lib\twill\other\u包
E:\twill-0.9\build\lib\twill
E:\twill-0.9\twill\extensions\match\parse
E:\twill-0.9\twill\扩展
E:\twill-0.9\twill\other\u packages\\u mechanize_dist
E:\twill-0.9\twill\other\u软件包
E:\twill-0.9\twill
下面是一个使用twill运行google搜索的例子,如果这有帮助的话。它显示了使用twill和beauthoulsoup一起解析网页:
不知道twill做什么(好吧,google),但是AppEngine提供了^{} function 可以用来获取网页。它还支持POST方法,例如登录。在
(我怀疑twill能在AppEngine中工作,因为AppEngine由于安全原因,python库有限。不过,只是猜测一下。)
要在appengine项目中使用第三方库,只需在部署时将它们包含在应用程序中即可。将twill文件夹(包含
__init__.py
)复制到应用程序的文件夹中并部署它。在看看twill Google代码项目,twill似乎在包中包含了它的依赖项(pyparsing、mechanize等),因此您可能不需要包含任何其他内容。在
相关问题 更多 >
编程相关推荐