Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
using mechanize to expand a collasped menu structure.by Anonymous Monk |
on Jul 04, 2006 at 15:09 UTC ( [id://559192]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: HI Monks. Can I request your help. I'm trying to use mechanize to click every links on a html page. There is a collaped menu on the page. Clicking on a link opens a node which reveals more collapased nodes. There are thousnads of them. My code is below. Its the first time I've used mechanize and html::tokeparse. I believe they work as follows, Its like a factory. The while loop powers the conveyer belt. The code is examined a token at a time, get_token() does this. get_tag() can be used when you want to get only a certain type of tag. It's similar to a person examining products on a factory production line. After being examined the tokens are either thown away or acted on. The IF clauses within the while loop, find the tokens we want and say how to act. The orginal html is stored in a string, this is kept and not modified. It's not possible to jump to a certain place in the string. Just like its not possible to jump to a certain place on a VHS cassete. How can I output the final page with all the menu nodes expanded? Anyway this is what I want to do. #1 search through html until the comment <!-- begin title ---> My code is below. the problem is occurring when trying to follow the link using $agent->get($a_href);. I'm getting an error main::searchHTML() called too early to check prototype at sitemech1.pl line 75. I've no idea what this means, should I be using a sleep function to wait for the page to reload?
Edited by planetscape - removed sensitive information from script
Back to
Seekers of Perl Wisdom
|
|