perl --- LWP::UserAgent
来源:互联网 发布:淘宝怎么批量定时上架 编辑:程序博客网 时间:2024/05/20 22:31
LWP::UserAgent --- web user agent class, is a class implementing aweb user agent. LWP::UserAgent objects can be used to dispatch webrequests.
use LWP::UserAgent;
use strict;
my $url = "http://www.myspace.cn";
my $ua = LWP::UserAgent->new(env_proxy => 1,
keep_alive => 1,
timeout => 15);
my $response = $ua->get($url);
if ($response->is_success) {
my $data = $response->content();
print "$data/n";
}
else {
print "/nfailed!/n";
}
In normal use the application creates an LWP::UserAgent object, andthen configures it with values for timeouts, proxies, name, etc. Itthen creates an instacne of HTTP::Request for the request that needs tobe performed. This request is then passed to one of the request methodthe UserAgent, which dispachtes it using the relevant protocol, andreturns a HTTP::Response object. There are convenience methods forsending the most common request types: get(), head() and post().
【Constructor methods】
$ua = LWP::UserAgent-> new(%options);
This method constructs a new LWP::UserAgent object and returns it.Key/Value pair arguments may be provided to set up the initial stgate. KEY DEFAULT
----------- --------------------
agent " libwww-perl/#.###"
from undef
conn_cache undef
cookie_jar undef
default_headers HTTP::Headers-> new
max_size undef
max_redirect 7
parse_head 1
protocols_allowed undef
protocols_forbidden undef
requests_redirectable ['GET', 'HEAD']
timeout 180
【Attributes】
The settings of the configuration attributes modify the behaviour ofthe LWP::UserAgent when it dispatches requests. Most of these can alsobe initialized by options passed to the constructor method.
$ua-> agent(),....
【Request Methods】
These methods are used to dispatch requests wia the user agent:
(1) $ua-> get($url)
(2) $ua-> get($url,$field_name-> $value,....)
These two methods will dispatch a Get Requests on the given $url.
(3) $ua-> head($url)
(4)$ua-> head($url,$field_name=> $value,...)
These two methods will dispatch a Head Request on the given $url.
(5) $ua-> post($url,/%form)
(6) $ua-> post($url,/@form)
- (7) $ua-> post( $url, /%form, $field_name => $value, ... )
- (8) $ua-> post( $url, $field_name => $value,... Content => /%form )
- (9) $ua-> post( $url, $field_name => $value,... Content => /@form )
- (10) $ua-> post( $url, $field_name => $value,... Content => $content )
These method will dispatch a POST
request on the given $url, with %form or @form providing the key/valuepairs for the fill-in form content. Additional headers and contentoptions are the same as for the get() method.
please see http://search.cpan.org/~gaas/libwww-perl-5.820/lib/LWP/UserAgent.pm for details
- perl --- LWP::UserAgent
- Perl 中关于 LWP::UserAgent等模块用法
- LWP::UserAgent HTTPs Debug
- LWP::UserAgent 模块
- Perl&LWP
- Perl & LWP
- PERL LWP
- perl LWP 网络编程
- perl and LWP 文档
- perl and LWP 文档
- perl&lwp经典用法
- perl&LWP 综述
- perl之LWP
- Perl LWP&HTTP
- PERL - LWP::SIMPLE 使用
- perl-lwp笔记
- Perl-LWP文档
- Perl LWP模块
- SQL SERVER 与ACCESS、EXCEL的数据转换
- c++内存分配(源于网络)
- VC实现文件拖拽
- perl---Staying in Control
- perl--- base module
- perl --- LWP::UserAgent
- XP系统下磁盘格式转换高招
- Java与.NET,谁是未来?
- 比Visio更实用的网页原型设计工具Axure RP Pro 5
- 3G(3rd Generation)
- 《HP大中华区总裁孙振耀退休感言》
- 代理网站
- Modern C++ Design 笔记 第十一章 MultiMethods(1)
- js定位菜单