I've run into a problem with mechanize following links. Here's a snippet of what I'm aiming to do:
for link in mech.links(url_regex='/test/'):
mech.follow_link(link)
// Do some processing on that link
mech.back()
According to mechanize examples, this should work just fine. However it doesn't. Despite calling .back(), the loop ends, even though there are more links to visit. If I comment out mech.follow_link(link) and mech.back(), replacing them with print link.text, it will print out all 50 or so links. However...as soon as I uncomment mech.follow_link, the loop immediately terminates after the first follow_link. back() is working, in that if I print mech.title(), then call mech.back() and print mech.title() again, it clearly shows the first title, then the 'back' page's title. I'm really confused, and this is how it's done in the docs. Not sure what's going on.