Perl的简单联网操作

本文最后更新于:2021年7月29日 下午

GET

1
2
3
4
5
6
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

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
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;
}


如果这篇文章对你有帮助,或者想给我微小的工作一点点资瓷,请随意打赏。
潘高 微信支付

微信支付

潘高 支付宝

支付宝


Perl的简单联网操作
https://blog.pangao.vip/Perl的简单联网操作/
作者
潘高
发布于
2017年9月26日 下午
更新于
2021年7月29日 下午
许可协议