Perl的簡單聯網操做

前言

更多內容,請訪問個人 我的博客html


GET

use LWP::UserAgent;

my $browser = LWP::UserAgent->new(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6');
my $TARGET_URL = "http://www.omim.org/entry/".$OMIM;
my $response = $browser->get($TARGET_URL);
my $htmlcontent = $response->content;
複製代碼

POST

use LWP::UserAgent;

my $browser = LWP::UserAgent->new;
$browser->timeout(600);	#設置緩衝時間600s
my $TARGET_URL = "http://122.114.25.231:8582/emp/selfOpenAccountAction!khQuery.action?step=xhdq";
my %headers=(
'Accept'=>'text/html, application/xhtml+xml, */*',
'Accept-Encoding'=>'gzip, deflate',
'Accept-Language' => 'zh-CN',
'Cache-Control' => 'no-cache',
'Connection' => 'Keep-Alive',
'Content-Length' => '71',
'Content-Type' => 'application/x-www-form-urlencoded',
'Cookie' => 'JSESSIONID=4D4E92EB8830CA8B5DC7F9AA1751AC71',
'Host' => '122.114.25.231:8582',
'Referer' => 'http://122.114.25.231:8582/emp/query.jsp',
'User-Agent' => 'Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko');
my $response = $browser->post($TARGET_URL,
[        
'dealer.certificateNum' => $id,
'dealer.name' => $name,
]
,%headers
); 
if ($response->is_success) { 
my $htmlcontentStr = $response->content;
}
複製代碼
相關文章
相關標籤/搜索