I question if you're able to help. I wish to write a script in python which will operate a query on the internet and output the outcomes from the query as

Thanks

adaptive

This will do what you would like:

>>> import twill.instructions

>>> import BeautifulSoup

>>>

>>> class browser:

...    def __init__(self, url="http://world wide web.google.com",log = None):

...       self.a=twill.instructions

...       self.a.config("readonly_controls_writeable", 1)

...       self.b = self.a.get_browser()

...       self.b.set_agent_string("Mozilla/5. (Home windows U Home windows NT 5.1 en-GB rv:1.8.1.14) Gecko/20080404 Opera/2...14")

...       self.log = log

...       self.b.obvious_snacks()

...       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 on(f, "btnG")

...       self.b.submit()

...       pageContent = self.b.get_html()

...       soup=BeautifulSoup.BeautifulSoup(pageContent)

...       ths = soup.findAll(attrs=)

...       for any in ths:

...          print a

...

>>> t=browser()

>>> t.googleQuery("twill queries")

==> at http://world wide web.google.ie/

Note: submit is applying submit button: title="btnG", value="SearchInch

<a href="http://pyparsing.wikispaces.com/WhosUsingPyparsing" class="l" onmousedown="return clk    (this.href,'','','res','1','','0CBMQFjAA')">pyparsing - WhosUsingPyparsing</a>

<a href="http://world wide web.mail-archive.com/twill@lists.idyll.org/msg00048.html" class="l" onmousedown="return clk(this.href,'','','res','2','','0CBcQFjAB')">Re: [<em>twill</em>] <em>query</em>: paperwork, and site.</a>

<a href="http://world wide web.mail-archive.com/twill@lists.idyll.org/msg00050.html" class="l" onmousedown="return clk(this.href,'','','res','3','','0CBkQFjAC')">Re: [<em>twill</em>] <em>query</em>: paperwork, and site.</a>

<a href="http://world wide web.genealogytoday.com/surname/finder.mv?Surname=Twill" class="l" onmousedown="return clk(this.href,'','','res','4','','0CB4QFjAD')"><em>Twill</em> Genealogy and Family Tree Assets - Surname Finder</a>

<a href="http://a706cheap-apparel.hobby-site.com/ladies-cotton-faded-twill-le-chameau-breeks-42" class="l" onmousedown="return clk(this.href,'','','res','5','','0CCEQFjAE')">Ladies Cotton Faded <em>Twill</em> Le Chameau Breeks 42</a>

<a href="http://twill.idyll.org/good examples.html" class="l" onmousedown="return clk(this.href,'','','res','6','','0CCMQFjAF')"><em>twill</em> Good examples</a>

<a href="http://panjiva.com/Sri-Lankan-Producers-Of/twill+capri" class="l" onmousedown="return clk(this.href,'','','res','7','','0CCcQFjAG')">Sri-Lankan <em>Twill</em> Capri Producers  Sri-Lankan Providers of <b>...</b></a>

<a href="http://c586cheap-apparel.dyndns.ws/twill-beige-blazer" class="l" onmousedown="return clk(this.href,'','','res','8','','0CCoQFjAH')"><em>Twill</em> beige blazer</a>

<a href="http://stackoverflow.com/questions/2267537/how-do-you-use-relative-pathways-for-twill-tests" class="l" onmousedown="return clk(this.href,'','','res','9','','0CCwQFjAI')">How would you use Relative Pathways for <em>Twill</em> tests? - Stack Overflow</a>

<a href="http://mytextilenotes.blogspot.com/2010/01/introduction-to-twill-weave.html" class="l" onmousedown="return clk(this.href,'','','res','10','','0CC8QFjAJ')">My Textile Notes: Summary of <em>Twill</em> Weave</a>

This example should assist you to.