Let me retry to explain what I need to do.

I am scraping a web page and I have $source which is the html dump. From the entire source code there is a table that has a ton of rows but always 2 columns (as you can see from the two samples above.

There is 1 URL in each table cell which means 2 URLS per table row. I need to collect the URL and the text of the URL for EACH table cell (which means 2 urls per row).

Those 2 samples displayed in the OP is what the table looks like. There's dozens upon dozens of <TR>s and I need to extract each url and the text for it and at the same time keep each row of links connected. This is to say I need to keep the two URLS per row together somehow because they are relative to each other. This code is the beginning of the table and 3 rows. You see it's just the same type of code I pasted earlier. I need the urls and the text but keep each row of data together magically.

<TABLE width=468 style="border-collapse:collapse"><TR><TD><TABLE width +=468 style="border-collapse:collapse" cellpadding=2> <TR><TD class=he +ad>Artist</TD><TD class=head>Song</TD></TR> <TR class=g><TD class=i><A href="/my-bloody-valentine-rxzg3.html">My B +loody Valentine</A></TD><TD class=j><A href="/my-bloody-valentine-lov +ely-sweet-darlene-9lgrnkb.html">Lovely Sweet Darlene *</A></TD></TR> <TR class=h><TD class=i><A href="/jennifer-love-hewitt-d193f.html">Jen +nifer Love Hewitt</A></TD><TD class=j><A href="/jennifer-love-hewitt- +i-want-a-love-i-can-see-jv2mj67.html">I Want A Love I Can See *</A></ +TD></TR> <TR class=g><TD class=i><A href="/jennifer-love-hewitt-d193f.html">Jen +nifer Love Hewitt</A></TD><TD class=j><A href="/jennifer-love-hewitt- +no-ordinary-love-4rftntr.html">No Ordinary Love *</A></TD></TR>
From that code I want to get /my-bloody-valentine-rxzg3.html and My Bloody Valentine from the first cell from the first table and ="/my-bloody-valentine-rxzg3.html and Lovely Sweet Darlene . I need this data collected for each row.

Does this make any more sense?

Edited by Chady -- escaped <TR>


In reply to Re^2: multiple regex matching by Anonymous Monk
in thread multiple regex matching by Anonymous Monk

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.