NAME

Novel::Robot::Browser

get/post url, return unicode content, auto detect CJK charset

自动化获取网页内容,并解码为unicode,主要是自动检测网页的中文字符集

FUNCTION

request_url

    my $browser = Novel::Robot::Browser->new();
	

get

my $url = 'http://www.jjwxc.net/onebook.php?novelid=2456';
my $content_get_ref = $browser->request_url($url);

post

    my $form_url = 'http://www.jjwxc.net/search.php';
    my $post_data = {
		'key1' => 'value1', 
		'key2' => 'value2', 
    };
    my $content_post_ref = $browser->request_url($form_url, $post_data);

request_urls

my $src_arr = [ 'http://www.ustc.edu.cn', 'http://202.38.64.10' ];
my $res = $browser->request_urls( $src_arr, 
    no_auto_request_url => 0, 
    select_url_sub => sub {
        my ($src_arr) = @_; 
        # ...
    }, 
    data_sub => sub { 
        my ($html_ref) = @_; 
        # ...
    }, 
    #request_sub => sub {
    #my ($r) = @_;
    # ...
    #return $data;
    #},
    show_progress_bar => 1, 
); 

request_urls_iter

my $src_arr = [ 'http://www.ustc.edu.cn', 'http://202.38.64.10' ];
my ($info, $url_list) = $browser->request_urls_iter( $url, 
    info_sub => sub { 
        my ($html_ref) = @_; 
        # ...
    }, 
    data_list_sub => sub { 
        my ($html_ref) = @_; 
        # ...
    }, 
    stop_sub => sub { 
        my ($info, $data_list) = @_; 
        # ...
    }, 
    url_list_sub => sub { 
        my ($html_ref) = @_; 
        # ...
    }, 
    select_url_sub => sub {
        my ($url_list) = @_; 
        # ...
    }, 
);