Net::Curl::Simple::UserAgent - share some data between multiple Net::Curl::Simple objects
use Net::Curl::Simple::UserAgent; # options for all out user agents Net::Curl::Simple::UserAgent->setopt( useragent => "My::Downloader", ); # this one uses socks for connection my $ua = Net::Curl::Simple::UserAgent->new( proxy => "socks5://localhost:9980/", ); # those two requests share cookies and options set before $ua->curl()->get( $uri, \&finished ); $ua->curl()->get( $uri2, \&finished ); sub finished { my ( $curl, $result ) = @_; print "document body: $curl->{body}\n"; }
Net::Curl::Simple::UserAgent provides a method to preset some options for multiple Net::Curl::Simple objects and allow them to share cookies.
Net::Curl::Simple::UserAgent
If setopt() or setopts() is called with package name and not an object, it will alter default UserAgent options. All newely-created user agents will share those options.
Creates new Net::Curl::Simple::UserAgent object.
my $ua = Net::Curl::Simple::UserAgent->new( timeout => 60 );
Set option for all new curl instances. It will not alter any curl instances created already.
Set multiple curl options.
Get new Net::Curl::Simple instance attached to this user agent. Options will be passed to new() constructor and will not affect any other instances.
Options can be either CURLOPT_* values (import them from Net::Curl::Easy), or literal names, preferably in lower case, without the CURLOPT_ preffix. The second method is preferred. For description of available options see curl_easy_setopt(3).
Net::Curl::Simple, Net::Curl::Simple::examples, Net::Curl::Easy, Net::Curl::Share
Copyright (c) 2011 Przemyslaw Iskra <sparky at pld-linux.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as perl itself.
To install Net::Curl::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Curl::Simple
CPAN shell
perl -MCPAN -e shell install Net::Curl::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.