Plain Old XML, a SOAP::Lite Alternative
PoXML is a drop-in replacement, of sorts, for the SOAP::Lite-less.
PoXML is a bit of home-brewed hackery for those who don’t have the SOAP::Lite [Hack #52] Perl module at their disposal. Perhaps you had more than enough trouble installing it yourself.
Tip
Any Perl guru will insist that module installation is as simple as can be. That said, any other Perl guru will be forced to admit that it’s an inconsistent experience and often harder than it should be.
PoXML is a drop-in replacement—to a rather decent degree—for SOAP::Lite. It treats Google’s SOAP as plain old XML, using the LWP::UserAgent module to make HTTP requests and XML::Simple to parse the XML response. And best of all, it requires little more than a two-line alteration to the target hack.
The Code
The heart of this hack is PoXML.pm
, a little
Perl module best saved into the same directory as your hacks.
# PoXML.pm # PoXML [pronounced "plain old xml"] is a dire-need drop-in # replacement for SOAP::Lite designed for Google Web API hacking. package PoXML; use strict; no strict "refs"; # LWP for making HTTP requests, XML for parsing Google SOAP use LWP::UserAgent; use XML::Simple; # Create a new PoXML sub new { my $self = {}; bless($self); return $self; } # Replacement for the SOAP::Lite-based doGoogleSearch method sub doGoogleSearch { my($self, %args); ($self, @args{qw/ key q start maxResults filter restrict safeSearch lr ie oe /}) = @_; # grab SOAP request from __DATA_ _ my $tell = tell(DATA); ...
Get Google Hacks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.