Perl的简单联网操作

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

-------------已经触及底线  感谢您的阅读-------------
潘高 wechat
公众号:潘高陪你学编程
如果你觉得这篇文章对你有帮助,或者想给我微小的工作一点点资瓷,请随意打赏。

本文标题:Perl的简单联网操作

文章作者:潘高

发布时间:2017年09月26日 - 13:23:22

最后更新:2019年03月08日 - 13:23:39

原始链接:https://blog.pangao.vip/Perl的简单联网操作/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。