Hello Monks,
I have spent the last two days trying to figure out why my short Perl script does not retrieve the text between <body> </body> of a website but got no luck. If you have time, please take a look and let me know why please. I am a beginner in Perl and HTML as well so take it easy on me please.
#!/usr/bin/perl -w
use LWP::UserAgent;
use HTTP::Request::Common;
# my $ua = LWP::UserAgent->new;
$ua = new LWP::UserAgent(keep_alive=>1,agent=>'Mozilla/5.0 (Windows; U
+; Windows NT 5.1; en-US; rv:1.9.2.11)
Gecko/20101012 Firefox/3.6.11');
# Create a request
my $response = $ua->post('http://www.sanmateocountytaxcollector.org/SM
+CWPS/SearchParcels',{parcelNumber=>'048022230',searchType=>'parcel',l
+istFirst=>'S',bkList=>'SS',addressTypeDsp=>'',addressType=>'',actionT
+ype=>'search',nextPage=>'./pages/parcelList.jsp',parcel1=>'048',parce
+l2=>'022',parcel3=>'230'});
my $u = $response->header('location') or die "missing location: ", $r
+esponse->as_string;
print "redirecting to $u\n";
# $r = $ua->get($u);
$r = $ua->simple_request(GET $u);
print $r->as_string;
Thank you for your help.
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.