-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebScraping.2.3.pl
More file actions
executable file
·38 lines (30 loc) · 942 Bytes
/
Copy pathwebScraping.2.3.pl
File metadata and controls
executable file
·38 lines (30 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl
use strict;
use WWW::Mechanize;
use HTML::TableExtract;
my $output_file = 'c:/temp/ire/car_people.csv';
my $starting_url = 'http://www.okiecar.org/nerds';
my $ua = WWW::Mechanize->new;
$ua->get( $starting_url );
#open OUT, ">$output_file";
my @states = ( 'TX','GA','DC','OK' );
for my $state ( @states ) {
$ua->form_name( 'byState' );
$ua->set_fields( state => $state );
$ua->click;
my $te = HTML::TableExtract->new;
$te->parse( $ua->content );
for my $table ( $te->tables ) {
my %data;
for my $row ( $table->rows ) {
$data{ $row->[0] } = $row->[1];
}
print $data{ 'Name:' }, ",",
$data{ 'Affiliation:' }, ",",
$data{ 'Address:' }, ",",
$data{ 'Phone:' }, ",",
$data{ 'Interests:' }, "\n";
}
$ua->back
}
#close OUT