[英]How to login in Perl using LWP::UserAgent and can check cookies value using HTTP::Cookies?
[英]How can I get the body of an HTTP response using LWP::UserAgent in Perl?
我發現LWP::UserAgent->request()
的返回包含HTTP響應的頭部和主體。 我只需要響應的主體做一些解析,那我該怎么辦?
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $response = $ua->get('http://search.cpan.org/');
if ($response->is_success) {
print $response->decoded_content; # or whatever
}
else {
die $response->status_line;
}
response->decoded_content
將返回響應的主體。
request
方法( 根據手冊 )返回HTTP :: Response對象,該對象具有content
方法。 打電話給那個。
$ua->request->content;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.