How can I put all twill commands together into one piece of code in a .py file?

Put your twill commands into a file, for example test.twill.

Put your twill commands into a file, for example test. Twill setlocal query "twill Python" go google.com/ fv 1 q $query submit btnI # use the "I'm feeling lucky" button show And then just pass filename as parameter to twill-sh command, like python twill-sh test. Twill And you might want to check .

Twill sample codes in tests folder of twill source test-back. Twill test-basic. Twill test-dns.

Twill test-equiv-refresh. Twill test-find. Twill test-form.

Twill test-formfill. Twill test-global-form. Twill test-go-exit.

Twill ....

S. Mark! I've tried Your way and something didn't work out there, but again trial-and-error method was a help.

Please refer to "Update 1" section above. Thank You for Your time. – brilliant Apr 22 '10 at 21:16 @ S.

Mark: "for update 1, you need to run python twill-sh test. Twill from command prompt" - Am I missing something important there? It just doesn't want to go through command prompt.

Please, take a look at the screen shot in "Update 2". Thank You. – brilliant Apr 23 '10 at 3:54 @ S.

Mark: "regarding update 2, looks like adding C:\Python25; to PATH environment variable didn't succeed"- Ouch! I am soooo sorry! It's my fault - I switched to another computer and didn't tell You about it.

I thought that informing You about the change of the path of my "twill-0.9" folder was just enough; and I completely forgot about this need to edit the "Path" environment variable! Yes, I just tried both Your quick method (twill-sh. Py) and the longer one (python twill-sh , with "Path" edited) - they both work!

It's interesting that if I do it one of – brilliant Apr 23 '10 at 6:17 1 @brilliant, regarding "result. Html", try save_html E:\tmp\twill-0.9\result. Html instead of save_html result.

Html – YOU Apr 23 '10 at 6:34 1 Welcome brilliant – YOU Apr 23 '10 at 10:32.

I think that instead of using the twill shell, you should instead directly call the functions using the twill python api twill.idyll.org/python-api.html.

Thank You, Nikwin. I think You are right - I really need to learn ho to do it from python shell. – brilliant Apr 22 '10 at 21:19.

Here it is in action (changed a wee bit): >>> import twill. Commands >>> import BeautifulSoup >>> >>> class browser: ... def __init__(self, url="google.com",log = None): ... self. A=twill.

Commands ... self.a. Config("readonly_controls_writeable", 1) ... self. B = self.a.

Get_browser() ... self.b. Set_agent_string("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1. 8.1.14) Gecko/20080404 Firefox/2.0.0.14") ... self.

Log = log ... self.b. Clear_cookies() ... self. Url=url ... def googleQuery(self, query="python code"): ... self.b.

Go(self. Url) ... #self.b.showforms() ... f = self.b. Get_form("f") ... #print "form is %s" % f ... f"q" = query ... self.b.

Clicked(f, "btnG") ... self.b.submit() ... pageContent = self.b. Get_html() ... soup=BeautifulSoup. BeautifulSoup(pageContent) ... ths = soup.

FindAll(attrs={"class" : "l"}) ... for a in ths: ... print a ... >>> t=browser() >>> t. GoogleQuery("twill queries") ==> at http://www.google.ie/ Note: submit is using submit button: name="btnG", value="Google Search" pyparsing - WhosUsingPyparsing Re: twill query: docs, and web site. Re: twill query: docs, and web site.

Twill Genealogy and Family Tree Resources - Surname Finder Ladies Cotton Faded Twill Le Chameau Breeks 42 twill Examples Sri-Lankan Twill Capri Manufacturers | Sri-Lankan Suppliers of ... Twill beige blazer How do you use Relative Paths for Twill tests? - Stack Overflow My Textile Notes: Introduction to Twill Weave >>> I use ubuntu so I use the following to install BeautifulSoup and twill: sudo apt-get install BeautifulSoup* sudo apt-get install python-twill* How this helps A.

Thank You, amadain, for this input. (Are You former user323303? ).

So, does it mean I have to download and install "Beautiful Soap" first? – brilliant May 20 '10 at 20:41 1 well beautifulsoup goes hand in hand with selenium and twill. Its very handy for parsing the pages once you get to the page you are looking for.

You don't have to download it but I would recommend using it if you are planning to use twill or selenium a lot – amadain May 21 '10 at 18:50 1 and yes I am former user323303 – amadain May 21 '10 at 18:52 I see. Thank You, amadain! (Sorry for the late response).

– brilliant May 23 '10 at 20:51.

Import string, re, sys, os import twill. Commands class browser: def __init__(self, url="google.com", query="python code", log = None): self. A=twill.

Commands self.a. Config("readonly_controls_writeable", 1) self. B = self.a.

Get_browser() self.b. Set_agent_string("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1. 8.1.14) Gecko/20080404 Firefox/2.0.0.14") self.

Log = log self.b. Clear_cookies() self. Url=url self.b.

Go(self. Url) f = self.b. Get_form("1") # self.log.

Debug("form is %s" % f) f"q" = query self.b.submit() self.log. Debug( "Links\n%s" % self.b.showlinks()) self.log. Debug( "Forms\n%s" % self.b.showforms()) pageContent = self.b.

Get_html() self.log. Debug("html is >" % pageContent).

Thank You, user323303, for providing this code. But I hardly understand a thing in it. I will take some time to study it.

– brilliant Apr 22 '10 at 21:18.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions