(c)AKAKE

Amazonから 注文レポートを取得する方法

category :[雑談] edit
Amazon アフィリエイトレポート
しげふみメモ:PlaggerでAmazonアソシエイトレポートをGmailへ送る

ここらへんを参照したんですが、「Amazon アソシエイト・セントラル」が
リニューアルされていて、そのままでは使えなくなっていました。
そこで これを元に修正して 現在使ってるのが以下のとおりになります。




#!/usr/local/bin/perl -w

use strict;
use MIME::Lite;
use WWW::Mechanize;

my $email = 'ログインID';
my $password = 'ログインパスワード';

my $start = "http://affiliate.amazon.co.jp/";

my $mech = WWW::Mechanize->new();
$mech->agent_alias('Windows IE 6');

$mech->get($start);

$mech->form_number(2);
$mech->field(email => $email);
$mech->field(password => $password);
$mech->click();

$mech->follow_link(url_regex => qr/reportType=earningsReport/);

$mech->form_number(3);
#$mech->field("reportType" => "earningsReport");
$mech->field("reportType" => "ordersReport");
#$mech->field("preSelectedPeriod" => "yesterday");
$mech->field("preSelectedPeriod" => "lastSevenDays");
#$mech->field("preSelectedPeriod" => "monthToDate");
#$mech->field("preSelectedPeriod" => "lastMonth");
#$mech->field("preSelectedPeriod" => "QuarterToDate");
$mech->click("submit.download_XML");

#メールで送信する場合
my $report = $mech->content();

my $mime = MIME::Lite->new(
To => $email,
From => $email,
Subject => "Amazon Affiliate Report",
Type => "text/plain; charset=Shift_JIS",
Encoding => "8bit",
Data => $report,
);
$mime->send();
#ファイルに書き出す場合
#open(OUT,'> amazon.xml');
#print OUT $report;
#close(OUT);
#print $report;


posted by AKAKE at 2007/08/03 13:23

Notice: Undefined index: HTTP_REFERER in /home/cosmosa/www/blog/topic.php on line 123