The following code gives me ALMOST what I want. I need the ID and then the name (between the > and <). I am not that familiar with regex, and got some help on this code here too. I am looking at the HTML::TokeParser right now, but it doesn't seem to be the ideal module for doing what I am doing. Any other module suggestions would be appreciated, but I also want to try and figure out how I can do this in regex.
Here is an example of the text I am combing through from the page:
<td colspan="6" bgcolor="#FFFFCC" class="SmallPrintBold"><a href="Plat
+formProductDetail.jsp?siteId=1&jid=3X223CA2D129EF993166683A761A7X4D&z
+sortParams=true&productId=26636&productType=2&catalog=1&authorId=9364
+0§ionId=0&platformId=1" >inMeeting</a> </td>
And here is my perl:
use LWP::Simple;
my %categories;
my $page = get('http://www.handango.com/PlatformTopSoftware.jsp?author
+Id=93640&zsortParams=true');
while ($page =~ /
productId=(\d+)
([^<]*)
<
/xig)
{
$categories{$1} = $2;
print "[$1] and [$2]\n";
}
foreach my $idkey (keys %categories)
{
print "$idkey,$categories{$idkey}\n";
}
This is what I get with this code:
[25297] and [&productType=2&catalog=1&authorId=93640§ionId=0&platf
+ormId=1"
>inChemLab]
[25297] and [">]
[26636] and [&productType=2&catalog=1&authorId=93640§ionId=0&platf
+ormId=1"
>inMeeting]
[26636] and [">]
[26632] and [&productType=2&catalog=1&authorId=93640§ionId=0&platf
+ormId=1"
>inTimeCard]
[26632] and [">]
[26641] and [&productType=2&catalog=1&authorId=93640§ionId=0&platf
+ormId=1"
>inShop]
[26641] and [">]
26636,">
26632,">
26641,">
25297,">
I would like to get just the ID and name, like:
26636,inMeeting
26641,inShop
Michael Jensen
michael at inshift.com
http://www.inshift.com
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.