Created
November 27, 2017 17:13
-
-
Save ryu1/4374642f3e6148fdc3f0c561ee8d5c00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!C:/Perl/bin/perl | |
| use strict; | |
| use HTTP::Request::Common; | |
| use LWP::UserAgent; | |
| use Jcode; | |
| ############ | |
| # 初期設定 # | |
| ############ | |
| # アップロード URL | |
| my $upload_url = "http://****; | |
| # ログイン ID | |
| my $login_id = '********'; | |
| # ログインパスワード | |
| my $login_pw = '********'; | |
| #################### | |
| # アップロード内容 # | |
| #################### | |
| # アップロードする ID(1〜50 の間の数字で省略すると空いている ID を利用する) | |
| my $upload_id = '0'; | |
| # タイトル(配信時にファイルを特定する文字列。省略するとファイル名になる) | |
| my $title = '**********'; | |
| # アップロードするファイル名(絶対パスか相対パスで指定してください) | |
| #my $filename = '**********'; | |
| my $filename = 'D:\**\*.csv'; | |
| #my $filename = 'D:\**\*.zip'; | |
| ############## | |
| # プログラム # | |
| ############## | |
| my $ua = LWP::UserAgent->new; | |
| my $oReq = | |
| POST $upload_url, | |
| Content_Type => 'form-data', | |
| Content => [ | |
| login_id => $login_id, | |
| password => $login_pw, | |
| id => $upload_id, | |
| title => $title, | |
| FILE => [$filename]]; | |
| my $res = $ua->request($oReq); | |
| my $content = $res->content; | |
| &Jcode::convert(\$content, 'euc','sjis', "z"); | |
| my @content = split("\n",$content); | |
| my %content = (); | |
| foreach my $line(@content){ | |
| my($key,$val) = split("=",$line); | |
| $content{$key} = $val; | |
| } | |
| if($res->is_error){ | |
| print STDERR "アップロードできませんでした\n".$content{ERROR}."\n"; | |
| exit; | |
| } | |
| print "アップロード ID(".$content{ID}.")でアップロードできました\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment