Last active
October 26, 2017 08:19
-
-
Save ngn999/64acb47b219f90666018 to your computer and use it in GitHub Desktop.
杭州小客车查询脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use LWP::UserAgent; | |
use Data::Dumper; | |
my $ua = LWP::UserAgent->new; | |
my $url = 'http://apply.hzcb.gov.cn/apply/app/status/norm/person'; | |
my $issueNumber = '201709'; | |
# get page count | |
my $response = $ua->post($url, 'Content' => {'pageNo'=>1, 'issueNumber' => $issueNumber, 'applyCode'=>''}); | |
my $page_count = 0; | |
if ($response->is_success) { | |
if ($response->content =~ /pageCount\s+=\s+window\.parseInt\('(\d+)',10\)/) { | |
$page_count = $1; | |
} | |
} | |
# <tr class="content_data"> | |
# <td >0035100864826</td> | |
# <td >华桂芳</td> | |
# </tr> | |
for (my $i = 1; $i <= $page_count; $i++ ) { | |
my $ua = LWP::UserAgent->new; | |
my $response = $ua->post($url, 'Content' => {'pageNo'=>$i, 'issueNumber' => $issueNumber, 'applyCode'=>''}); | |
if ($response->is_success) { | |
if (my @all = $response->content =~ m{class="content_data">\s+<td\s+>\d+</td>\s+<td\s+>(.*?)</td>}g) { | |
foreach (@all) { | |
print; | |
print "\n"; | |
} | |
} | |
} | |
sleep 0.5; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment