How to combine twill and python into one code that could be run on "Google App Engine"?

Posted by brilliant on Stack Overflow See other posts from Stack Overflow or by brilliant
Published on 2010-04-26T22:19:50Z Indexed on 2010/04/26 22:23 UTC
Read the original article Hit count: 347

Filed under:
|
|
|

Hello everybody!!!

I have installed twill on my computer (having previously installed Python 2.5) and have been using it recently.

Python is installed on disk C on my computer: C:\Python25

And the twill folder (“twill-0.9”) is located here: E:\tmp\twill-0.9

Here is a code that I’ve been using in 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

This code helps me to log in to one website, in which I have an account, record the HTML code of some other page of that website (that I can access only after logging in), and store it in a file named “result.txt” (of course, before using this code I firstly need to replace “my login” with my real login, “my password” with my real password, “some website’s sign-in page URL” and “URL of some other page from that website” with real URLs of that website, and number 2 with the number of the form on that website that is used as a sign-in form on that website’s log-in page)

This code I store in “test.twill” file that is located in my “twill-0.9” folder: E:\tmp\twill-0.9\test.twill I run this file from my command prompt: python twill-sh test.twill

Now, I also have installed “Google App Engine SDK” from “Google App Engine” and have also been using it for awhile.

For example, I’ve been using this code:

import hashlib
m = hashlib.md5()
m.update("Nobody inspects")
m.update(" the spammish repetition ")
print m.hexdigest()

This code helps me transform the phrase “Nobody inspects the spammish repetition” into md5 digest.

Now, how can I put these two pieces of code together into one python script that I could run on “Google App Engine”?

Let’s say, I want my code to log in to a website from “Google App Engine”, go to another page on that website, record its HTML code (that’s what my twill code does) and than transform this HTML code into its md5 digest (that’s what my second code does). So, how can I combine those two codes into one python code?

I guess, it should be done somehow by importing twill, but how can it be done? Can a python code - the one that is being run by “Google App Engine” - import twill from somewhere on the internet? Or, perhaps, twill is already installed on “Google App Engine”?

© Stack Overflow or respective owner

Related posts about twill

Related posts about python