1 #This lwp::useragent is generally used in conjunction with other modules2 #比如:3 #HTTP:: Request4 #HTTP:: Cookies5 #HTTP:: Respose6 #HTTP:: Status7 #LWP:: useragent equivalent to creating a mock browser8 9 #用以下方式创一个浏览器Ten my $useragent= lwp::useragent->new (); One #In general, we do not add the parameters, to the following time to add, or let it use the default values, its default parameters are as follows A -=pod - KEY DEFAULT the----------- -------------------- -Agent"libwww-perl/#.###" -Fromundef -Conn_cacheundef +Cookie_jarundef -Default_headers http::headers->New +Local_addressundef Assl_opts {verify_hostname =1 } atMax_sizeundef -Max_redirect7 -Parse_head1 -Protocols_allowedundef -Protocols_forbiddenundef -requests_redirectable ['GET','HEAD'] inTimeout the -=Cut to +If you want to add parameters, use this form: - my $useragent= Lwp::useragent->new (Agent = ='PERL'); the=pod * In general, we don't have to configure the parameters above him. $ of course, if you want to test, you can use the following code to print the default value, but not necessarily to print properlyPanax Notoginseng=Cut - the #!/usr/bin/perl-w + UseStrict; A UseLWP::useragent; the + my $ua= lwp::useragent->new (); - Print $ua->agent,"\ n"; $ Print $ua->from,"\ n"; $ Print $ua->conn_cache,"\ n"; - Print $ua->cookie_jar,"\ n"; - Print $ua->default_headers,"\ n"; the Print $ua->local_address,"\ n"; - Print $ua->ssl_opts,"\ n";Wuyi Print $ua->max_size,"\ n"; the Print $ua->max_redirect,"\ n"; - Print $ua->parse_head,"\ n"; Wu Print $ua->protocols_allowed,"\ n"; - Print $ua->protocols_forbidden,"\ n"; About Print $ua->requests_redirectable,"\ n"; $ Print $ua->timeout,"\ n"; - - #you can see that some values are to be obtained from other modules, like $ua->default_headers, to be built from Http::headers->new
Lwp::useragent Introduction 2