Greeings fellow coders,
I'm somewhat new working with perl. I am attempting to automate pulling some information from a wholesale providers website who does not offer an API for it's retailers, i.e. scape some information from a page.
I can successfully login to the https site and navigate to the page which should contain the content, but the "generated content" is missing. So as to not draw a false conclusion, to verify that there is content, I have logged into the site via the browser and indeed there is content. And I can "view source" and see the tabled information I ultimately want to get to via a script. Here is the code I use in my attempt. I've also played aroung with the LPW:UserAgent with less success. For obvious reasons, the site, user, and password has been changed. I am asking for any assistance one might have with much more experience with this. Thank you very much.
#!/usr/bin/perl -w
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
my $outfile = "out.htm";
my $url = "https://www.mywholesalersite.com/frmLogin.aspx";
my $username = 'user';
my $password = 'passwd';
my $mech = WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);
$mech->form_name('Form1');
$mech->field(login => $username);
$mech->field(passwd => $password);
$mech->click();
sleep 3;
# We are now logged in. This is verified by viewing the $mech->conten
+t
$url = 'https://www.mywholesalersite.com/frmReportLineCount.aspx';
$mech->get( $url );
sleep 15; # Allow time for content to be generated
$mech->save_content( $outfile );
exit;
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.