I am using Randal's form ripper script
(
http://www.stonehenge.com/merlyn/WebTechniques/col43.html )
to pull some data from GoogleAds then extract data from the HTML using
HTML::TableExtract.
I am
NOT an expert in LWP, but I've used Randal's script successfully elsewhere.
Now I am befuddled.
I
think I am running into problems as the page uses HTTPS vs. HTTP.
Here's the error I'm encountering:
C:\Inetpub\wwwroot\google\GoogleTools>perl gt_refresh.pl
Can't locate object method "method" via package "HTTP::Headers" (perha
+ps you for got to load "HTTP::Headers"?) at C:/Perl/site/lib/HTTP/Mes
+sage.pm line 189.
And here's my code:
package GoogleCampaignData;
use HTML::TableExtract;
use LWP::UserAgent;
use HTTP::Request::Common;
use strict;
sub new {
my ($class, $campid) = @_;
my $self = {};
_init($self, $campid);
bless($self, $class);
return $self;
}
sub _init {
my ($self, $campid) = @_;
my $ua = LWP::UserAgent->new;
$ua->env_proxy;
my $req =
$ua->request(POST "https://adwords.google.com/reports/ads",
[
# "seshid" => "XXXXXX", # hidden
"campaign" => $campid,
"when" => "campaignlife", # campaign to date
"mode" => "keywords", # by keyword URL -- this is critic
+al
"keywords_criteriaSort" => "parameters", # by keyword
"byposition" => "1", # differentiate pos1 and pos2
"display_format" => "html", # HTML results
"submit2" => "Generate Report" # do it
],
Referer => "http://ads.google.com/reports/ads?username=XX
+XX&password=XXXX",
);
my $content = $ua->request($req)->as_string;
die $content; # FOR DEBUGGING -- SHOW WE GOT SOMETHING
}
1;
nop
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.