Perl

use LWP::UserAgent;post

$user_agent = new LWP::UserAgent;get

$request = new HTTP::Request('GET', 'http://www.chengxuyuans.com');it

$response = $user_agent->request($request);request

open FILEHANDLE, "> C:\oschina1.txt";請求

print FILEHANDLE $response->{_content};im

close FILEHANDLE;co

#use LWP::UserAgent; use HTTP::Request; use HTTP::Response; $ua = LWP::UserAgent->new(timeout=>180); $request = HTTP::Request->new('POST'=>"http://mysite.com?name=john"); $request->content('age=18'); #post 請求參數 $request->header('Accept-Language', 'zh-CN,zh;q=0.8'); $response = $ua->request($request); print $response->content(); print $response->status_line(); print $response->header('Content-Type');header

相關文章
相關標籤/搜索