Gossamer Forum
Home : General : Perl Programming :

Google Scrapping

Quote Reply
Google Scrapping
Hi all I don't know a whole lot about perl but I really would like to get a script to work which pulls information from a google query and puts it into comma delimited text. I found this script from o'rilly but it seems to be missing alot of stuff does anyone know enough about perl to fix this script or figure out how to add input to it?



Thanks


Code:
#!/usr/bin/perl
# phonebook2csv
# Google Phonebook results in CSV suitable for import into Excel
# Usage: perl phonebook2csv.pl < results.html > results.csv

# CSV header
print qq{"name","phone number","address"\n};

my @listings = split /<hr size=1>/, join '', <>;

foreach (@listings[1..($#listings-1)]) {
s!\n!!g; # drop spurious newlines
s!<.+?>!!g; # drop all HTML tags
s!"!""!g; # double escape " marks
print '"' . join('","', (split /\s+-\s+/)[0..2]) . "\"\n";
}

Last edited by:

Wil: Jun 7, 2003, 4:40 AM