Since it looks like calc HW you're getting and not computer HW, here's a hint:
#!/usr/bin/perl # find calc homework use strict; use warnings; use HTML::TreeBuilder; my $date='4/27/012'; #set the date, you can do this dynamically my $url= 'http://staweb.sta.cathedral.org/departments/math/mhansen/pub +lic_html/1112hcal/1112hcal.htm'; # get the page and make a tree structure out of it my $tree= HTML::TreeBuilder->new_from_url($url); #break the table into rows my @elements = $tree->find_by_tag_name('tr'); #loop through the rows looking for the date #and use the as_trimmed_text to get rid of all the extra htmlness foreach (@elements){ if((my $hw=$_->as_trimmed_text())=~m%$date%){ print $hw."\n"; } }

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 reply to Re^2: Getting Text from Website by bitingduck
in thread Getting Text from Website by LaneM1234

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.