use SOAP::Lite. Need 0.52 or greater.<xsd:complexType name="ResultElement"> <xsd:all> <xsd:element name="summary" type="xsd:string"/> <xsd:element name="URL" type="xsd:string"/> <xsd:element name="snippet" type="xsd:string"/> <xsd:element name="title" type="xsd:string"/> <xsd:element name="cachedSize" type="xsd:string"/> <xsd:element name="relatedInformationPresent" type="xsd:boolean"/> <xsd:element name="hostName" type="xsd:string"/> <xsd:element name="directoryCategory" type="typens:DirectoryCategory"/> <xsd:element name="directoryTitle" type="xsd:string"/> </xsd:all> </xsd:complexType>
use constant LOCAL_GOOGLE_KEY => "********************************";
my $googleSearch = SOAP::Lite ->service("file:\\googleapi\\GoogleSearch.wsdl");
my $query = 'hello world';
my $result = $googleSearch -> doGoogleSearch(LOCAL_GOOGLE_KEY, $query, 0,
10, "false","", "false", "", "latin1", "latin1");
for (@{$result->{"resultElements"}}) {
print $_->{"URL"}."\n";
}
use Net::Google, which gives a nice OO interface.
use Net::Google;
use constant LOCAL_GOOGLE_KEY => "********************************";
my $google = Net::Google->new(key=>LOCAL_GOOGLE_KEY);
my $search = $google->search();
my $query = 'hello world';
$search->query($query);
for (@{$search->results()}) {
print $_->URL()."\n";
}
These are some notes for a quick presentation I did for Ottawa Perl Mongers as part of a roundtable session we had on March 12, 2003.