2015年1月19日 星期一

Send HTML POST data by Perl LWP

Reference:
How do I send POST data with LWP?

use LWP::UserAgent;
$ua = LWP::UserAgent->new();
$url = "http://www.twse.com.tw/ch/trading/exchange/MI_INDEX/MI_INDEX.php";

$today7 = "1040115";
$response = $ua->post( $url, { 'download' => 'csv',  'qdate' => $today7, 'selectType' => 'ALLBUT0999'} );
$content  = $response->decoded_content();
my $file = 'stocks_twse.csv';
open $FH_o, ">", $file;
print $FH_o $content;
close $FH_o;

沒有留言:

張貼留言