Search Altavista with Perl and LWP
LWP is short for libwww-perl, which is a collection of WWW modules for Perl. With LWP you can easily access most web protocols, such as HTTP, HTTPS and FTP. LWP is used in this script in order to retrieve data from an Altavista search. The modules used here are:
- LWP::Simple
- LWP::UserAgent
- HTTP:Response
LWP::Simple is a very basic module of LWP, which supports simple GET commands. LWP::UserAgent creates the user-agent, a simulated web browser. HTTP::Response is used to treat the response you recieve from LWP::Simple.
To search Altavista automatically, LWP gets the URL to which you are forwarded when you enter a keyword in the search form of Altavista. This script uses regular expressions to find the first non-sponsored search result from that URL.
# Include the relevant modules use LWP::Simple; use LWP::UserAgent; use HTTP::Response; # Print some nice instructions print "Type string"; # Continually read from standard input while () { # Remove the line end (\n, \r or \n\r) chomp; # Create the "browser" my $browser = LWP::UserAgent->new; # Define the URL. $_ is the chomped and substituted input my $url = "http://www.altavista.com/web/results?q=" . $_; # Get the response from the Altavista server my $response = $browser->get($url); # Get the content from the response $_ = $response->content; # Match the first non-sponsored result with a regular expression m/a class='res' href='.*?'(.*?)\/a .*?span class=ngrn(.*?)\/span/; # Get the search result's URL my $gurl = "http://" . $2; # Get the search result's title my $title = $1; # Print the result! print "$title \n $gurl \n"; }
Disclaimer: I would never use Altavista manually, because I love Google and everything it does with all of my heart. I first tried this with Google, but I didn’t get it to work. Instead of solving the problem, I just changed to Altavista. My apologies.2 wayne lil ringtone carterfree tone nokia ringtone 6310ialaddin ringtones htmringtone phone download alltelfree ringtone music phone alltelpics amanda harringtonsanyo ringtone 5300 freepolyphonic adam ringtone g Maponline22 levitra 22buymg 10 20 vs mg levitrait acid reflux levitra amerimedrx wetrackb2 c 1 by powered levitradose 1597 1108 levitra171 b b levitra 1191230 20mg levitra 17721920 1333 levitra info Mapamateur porn xxxpornholio amateurcreampies lucysgotlegs gigagalleriesporn movies amateureporn amateurhousewifeamateurpornoporn amateurs vidsamatoriali filmati porno videoporn amatuare Map
