I’m sorry to have to ask something like this but python’s mechanize documentation seems to really be lacking and I can’t figure this out.. they only give one example that I can find for following a link:
response1 = br.follow_link(text_regex=r"cheese\s*shop", nr=1)
But I don’t want to use a regex, I just want to follow a link based on its url, how would I do this.. also what is “nr” that is used sometimes for following links?
Thanks for any info
br.follow_linktakes either aLinkobject or a keyword arg (such asnr=0).br.links()lists all the links.br.links(url_regex='...')lists all the links whose urls matches the regex.br.links(text_regex='...')lists all the links whose link text matches the regex.br.follow_link(nr=num)follows thenumth link on the page, with counting starting at 0. It returns a response object (the same kind what br.open(…) returns)br.find_link(url='...')returns theLinkobject whoseurlexactly equals the given url.br.find_link,br.links,br.follow_link,br.click_linkall accept the same keywords. Runhelp(br.find_link)to see documentation on those keywords.Edit: If you have a target url that you wish to follow, you could do something like this: