Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Sucking Data off a Web Page

by tachyon (Chancellor)
on Oct 10, 2004 at 06:14 UTC ( [id://397963]=note: print w/replies, xml ) Need Help??


in reply to Sucking Data off a Web Page

Note that this may be against their terms of service and that you may cripple their server if you are not careful to limit your request rate. For good luck here are 7 lines to get you started.

use LWP::Simple; my $data = get( "http://www.speedtrap.org/speedtraps/ste.asp?city=all& +state=AK" ); for my $chunk ( split /<table border="1" width="100%"/, $data ) { next unless $chunk =~ m/Jurisdiction/; @data = $chunk =~ m!<td width="66%" bgcolor="#FFFFFF">\s*(.*?)\s*< +/td>!gs; my $csv = join ',', map{ s!</?[^>]+>!!g; s!"!\\"!g; qq!"$_"! } @da +ta; print "$csv\n"; }

cheers

tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://397963]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found