Python mechanize find_link find the final matching link?

You could use br.links() to generate all such links, then use list(...)-1 to pick off the last one.

You could use br.links() to generate all such links, then use list(...)-1 to pick off the last one: lastLink = list(br. Links(text_regex=re. Compile("Display charges")))-1 For example: In 29: import mechanize In 30: import re In 31: br=mechanize.Browser() In 32: br.

Open('example.com') Out32: >> In 33: br.links() Out33: In 34: list(br.links()) Out34: Link(base_url='http://www.iana.org/domains/example/', url='/', text='HomepageIMG', tag='a', attrs=('href', '/')), Link(base_url='http://www.iana.org/domains/example/', url='/domains/', text='Domains', tag='a', attrs=('href', '/domains/')), Link(base_url='http://www.iana.org/domains/example/', url='/numbers/', text='Numbers', tag='a', attrs=('href', '/numbers/')), Link(base_url='http://www.iana.org/domains/example/', url='/protocols/', text='Protocols', tag='a', attrs=('href', '/protocols/')), Link(base_url='http://www.iana.org/domains/example/', url='/about/', text='About IANA', tag='a', attrs=('href', '/about/')), Link(base_url='http://www.iana.org/domains/example/', url='/go/rfc2606', text='RFC 2606', tag='a', attrs=('href', '/go/rfc2606')), Link(base_url='http://www.iana.org/domains/example/', url='/about/', text='About', tag='a', attrs=('href', '/about/')), Link(base_url='http://www.iana.org/domains/example/', url='/domains/', text='Domains', tag='a', attrs=('href', '/domains/')), Link(base_url='http://www.iana.org/domains/example/', url='/protocols/', text='Protocols', tag='a', attrs=('href', '/protocols/')), Link(base_url='http://www.iana.org/domains/example/', url='/numbers/', text='Number Resources', tag='a', attrs=('href', '/numbers/')), Link(base_url='http://www.iana.org/domains/example/', url='http://www.icann.org/', text='Internet Corporation for Assigned Names and Numbers', tag='a', attrs=('href', 'http://www.icann.org/')), Link(base_url='http://www.iana.org/domains/example/', url='mailto:iana@iana. Org? Subject=General%20website%20feedback', text='[email protected]', tag='a', attrs=('href', 'mailto:iana@iana.

Org? Subject=General%20website%20feedback')) In 35: list(br. Links(text_regex=re.

Compile("About"))) Out35: Link(base_url='http://www.iana.org/domains/example/', url='/about/', text='About IANA', tag='a', attrs=('href', '/about/')), Link(base_url='http://www.iana.org/domains/example/', url='/about/', text='About', tag='a', attrs=('href', '/about/')).

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