Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
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

In reply to How to scraper ASP websites 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!
  • 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:
    & &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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (9)
    As of 2014-12-18 23:59 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (69 votes), past polls