|
|
| Don't ask to ask, just ask | |
| PerlMonks |
Re^2: Getting Text from Websiteby bitingduck (Friar) |
| on Jun 22, 2012 at 06:25 UTC ( #977783=note: print w/ replies, xml ) | Need Help?? |
|
Since it looks like calc HW you're getting and not computer HW, here's a hint:
It takes approach 1 that aaron_baugher describes, but mostly ignores the details of the page structure. We know it's a table and we want the rows. Knowing that the first column is just the day and date, I'm going to assume we want to keep them anyway. The find_by_tag_name just gets all the rows and all the stuff inside them. There's a bunch of <p> and <span> tags that really aren't interesting, so I take the lazy approach and use as_trimmed_text to throw those away and just keep the contents of the two cells all together. It's also useful to know that HTML::TreeBuilder gets a bunch of methods from HTML::Element. Update: tweaked the code formatting to keep the comments from wrapping ...And to note that some of your assignments have links in them-- you can use HTML::Element to dig those out before you apply as_trimmed_text, or dig them out an of other various possible ways.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||