![](/img/trans.png)
[英]How to make the post request in BOX API using LWP::UserAgent?
[英]How do I make a progress bar using Term::ProgressBar with LWP::UserAgent's post method?
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common;
use HTML::TreeBuilder;
use Cwd 'realpath';
use warnings;
use strict;
my $ua = LWP::UserAgent->new();
my $response = $ua->request(
POST 'http://mydomain.com/upload.php',
'Content-Type' => 'multipart/form-data',
'Content' => [ 'fileup' => [realpath(shift)] ],
);
my $tree = HTML::TreeBuilder->new_from_content($response->decoded_content);
my $image = $tree->look_down('_tag','a',sub { $_[0]->{href} =~ /http:\/\/images.mydomain.com\/images\/[^\?]/ if $_[0]->{href}})->{href};
print "\n".$image."\n\n";
如何為此顯示上傳的腳本創建進度條? :content_cb讓我們在上傳圖片后為響應創建進度條,那么如何為上傳本身做呢?
這不能回答您最初的問題,但是也許您可以使用內置的進度條來代替:
$ua->show_progress
$ua->show_progress( $boolean )
Get/set a value indicating whether a progress bar should be displayed on on the
terminal as requests are processed. The default is FALSE.
(來自LWP :: UserAgent POD)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.