perl lwp 超时问题

来源:互联网 发布:国税发票打印软件 编辑:程序博客网 时间:2024/05/21 01:29
lwp 超时问题:jrhmpt01:/root/async# cat a1.pl use  LWP::UserAgent;use utf8;use DBI;use POSIX;use Data::Dumper;use HTML::TreeBuilder;  use HTML::TreeBuilder::XPath;my $ua = LWP::UserAgent->new;$ua->timeout(10);$ua->env_proxy;$ua->agent("Mozilla/8.0");#my $response = $ua->get('http://data.10jqka.com.cn/financial/yjyg/date/2016-03-31/board/ALL/field/enddate/order/desc/page/1/ajax/1/');#my $response = $ua->get('http://data.10jqka.com.cn/financial/yjyg/');my $response = $ua->get('http://120.55.11x.6:3000/api/env?ip=192.168.32.101');if ($response->is_success) {print   $response->decoded_content;  # or whatever}else{print   $response->decoded_content; };设置超时时间为 $ua->timeout(10);结果如下:jrhmpt01:/root/async# time perl a1.pl500 read timeoutreal0m10.192suser0m0.169ssys0m0.016s服务端在10秒内没返回,就超时

0 0
原创粉丝点击