Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Publishing Associates Statistics Help

by osmaster
on Apr 18, 2005 at 16:27 UTC ( #448937=perlquestion: print w/replies, xml ) Need Help??

osmaster has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Publishing Associates Statistics Help

Replies are listed 'Best First'.
Re: Publishing Associates Statistics Help
by dynamo (Chaplain) on Apr 18, 2005 at 17:25 UTC
    Next time you post here asking for help, please try to make it a little easier for us to help you. Some of the following things would have been nice, and probably would have gotten your question answered faster:
    • Copy and paste the code you are interested in fixing into your post.
    • Explain what you tried to do to get it to work that didn't work.
    • Explain what the code is supposed to do, and what happens when you try it. Describe the kind of system you tried it on .. OS, perl version, whatever else you think is relevant.
    • Explain what errors you are getting and where.
    • If you refuse to copy and paste the code, at least make the URL for the code be a clickable link (if you don't know how, check out the Writeup Formatting Tips node, it's also linked to near the bottom of the preview page you see when writing nodes.)

    Having said that, I had a look. I don't have an Amazon Associates account to try it on, but when I tried running the code as is, I got a bunch of uninit errors - the first of which seems to trace back to missing values in the @fromdate array.
    The @fromdate array reads from the second line of the URL request result from amazon. I'd try to manually build an html form page that calls the right url with the right parameters, and see what it's returning. Then try to fix yourself, or come back to perlmonks with your new information.

Re: Publishing Associates Statistics Help
by gam3 (Curate) on Apr 18, 2005 at 20:31 UTC
    The lay out of the page that you are trying to parse has changed, and it would be ver hard to fix that script. I would suggest using WWW::Mechanize to do the parse.
    -- gam3
    A picture is worth a thousand words, but takes 200K.
Re: Publishing Associates Statistics Help
by cog (Parson) on Apr 18, 2005 at 16:32 UTC
    Sure. What errors?
Re: Publishing Associates Statistics Help
by eibwen (Friar) on Apr 18, 2005 at 17:45 UTC
    Could you elaborate on the problem you're encountering?

    `perl -c` verifies the syntax of the code is OK. I don't have an Amazon Associates account to actually test the code myself, but upon visual inspection the only potential problem that I can readily identify is that Amazon may have changed it's URLs; however if the URL is still valid it may be a parsing error. To this end find the following section of the source:

    # Uncomment the following line to see # the report if you need to debug. # print $report->content;

    And uncomment the last line. Please provide any code output, error messages, et all.

Re: Publishing Associates Statistics Help
by Anonymous Monk on Apr 18, 2005 at 20:18 UTC
    #!/usr/bin/perl -w # # # Logs into Amazon, downloads earning report, # and writes an HTML version for your site. # Usage: perl use strict; use URI::Escape; use HTTP::Cookies; use LWP::UserAgent; use Net::SSLeay; # Set your Associates account info. my $email = ''; my $pass = 'mypasswordhere'; my $aftag = 'amazonid'; # Create a user agent object # and fake the agent string. my $ua = LWP::UserAgent->new; $ua->agent("(compatible; MSIE 4.01; MSN 2.5; AOL 4.0; Windows 98)"); $ua->cookie_jar({}); # in-memory cookie jar. # Request earning reports, logging in as one pass. my $rpturl = "". "network/reports/main.html"; my $rptreq = HTTP::Request->new(POST => $rpturl); my $rptdata = "report-type=shipments-by-item". # get individual item +s "&date-selection=qtd". # all earnings this q +uarter "&login_id=".uri_escape($email). # our email address. "&login_password=".uri_escape($pass). # and password. "& my report". # get downloadble +. "&enable-login-post=true"; # log in and post at once. $rptreq->content_type('application/x-www-form-urlencoded'); $rptreq->content($rptdata); my $report = $ua->request($rptreq); print $report->content; # Set the report to array. my @lines = split(/\n/, $report->content); # Get the time period. my @fromdate = split(/\t/, $lines[1]); my @todate = split(/\t/, $lines[2]); my $from = $fromdate[1]; my $to = $todate[1]; # Print header... print "<html><body>"; print "<h2>Items Purchased Through This Site</h2>"; print "from $from to $to <br><br>\n"; print "<ul>"; # Loop through the rest of the report. splice(@lines,0,5); foreach my $line (@lines) { my @fields = split(/\t/, $line); my $title = $fields[1]; my $asin = $fields[2]; my $edition = $fields[4]; my $items = $fields[8]; # Format items as HTML for display. print "<li><a href=\"$asin/ref=nosim/ +". "$aftag\">$title</a> ($items) $edition <br>\n"; } print "</ul></body></html>"; And this is my error: C:\Perl>perl Can't locate auto/Net/SSLeay/autosplit.ix in @INC (@INC contains: C:/P +erl/lib C: /Perl/site/lib .) at C:/Perl/lib/ line 160. at C:/Perl/lib/Net/ line 61 Can't locate loadable object for module Net::SSLeay in @INC (@INC cont +ains: C:/P erl/lib C:/Perl/site/lib .) at line 11 Compilation failed in require at line 11. BEGIN failed--compilation aborted at line 11.
    I have Windows XP. Is NET:SSLeay a current Perl Module, should I be using something else? How to I do HTTPS requests?
      Net::SSLeay is a Perl module you will have to install from CPAN or with PPM.


      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Publishing Associates Statistics Help
by Anonymous Monk on Apr 18, 2005 at 20:21 UTC
    All I want to to is log on to the Amazon associates web site, downloads my earning report, and writes an HTML version for my site.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://448937]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (1)
As of 2021-05-09 14:10 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (100 votes). Check out past polls.