hi,
I've one of my asp websites and I want to run a daily scrapper to keep a track of all data.
Issue is that the site is in asp and on fetching the contents the contents is something in coded form.
I tried WWW::Mechanize but the same output in javascript and encoded form.
I tried WWWW::Mechanize::Firefox but it was not even able to login to the website, it simply says no such fields found
Then I go with HTML::TreeBuilderX::ASP_NET, but I could not understand exactly how to use it.
Even in mechanize I tried to post the __EVENTVALIDATION and __VIEWSTATEbut again No Luck there too.
Can anyone help me in this, posting here is the sample WWW::Mechanize program:
#!/usr/bin/perl
use WWW::Mechanize;
my $mech = WWW::Mechanize->new(autocheck => 0, autodie => 0);
$mech->agent('wonderbot/JS 1.0');
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get('https://XXXXX.aspx');
my $email = 'XXXX';
my $password = 'XXXX';
my $org_id = 'XXXXXX';
$mech->form_id('loginForm');
$mech->field('sUserName' => $email);
$mech->field('sPassword' => $password);
$mech->field('sParentUID' => $org_id);
#$mech->field('__EVENTVALIDATION' => $__EVENTVALIDATION);
#$mech->field('__VIEWSTATE' => $__VIEWSTATE);
$mech->click();
$mech->get('https://YYYY.aspx');#going to another link on the same web
+site
my $html_string = $mech->content();
print $html_string;
Code for WWW::Mechanize::Firefox:
#!/usr/bin/perl
use WWW::Mechanize;
my $mech = WWW::Mechanize->new(autocheck => 0, autodie => 0);
$mech->agent('wonderbot/JS 1.0');
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get('https://XXXXX.aspx');
my $email = 'XXXX';
my $password = 'XXXX';
my $org_id = 'XXXXXX';
$mech->form_id('loginForm');
$mech->field('sUserName' => $email);
$mech->field('sPassword' => $password);
$mech->field('sParentUID' => $org_id);
#$mech->field('__EVENTVALIDATION' => $__EVENTVALIDATION);
#$mech->field('__VIEWSTATE' => $__VIEWSTATE);
$mech->click();
$mech->get('https://YYYY.aspx');#going to another link on the same web
+site
my $html_string = $mech->content();
print $html_string;
Any help in this would be deeply regarded.
Thanks
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
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.
|
|