NAME
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 $url = 'http://www.jjwxc.net/onebook.php?novelid=14089';
my $res = $browser->request_urls( $url,
#post_data => ...,
info_sub => sub {
my ($html_ref) = @_;
# ...
},
url_list_sub => sub {
my ($src_arr) = @_;
# ...
},
#min_item_num => ...,
#max_item_num => ...,
content_sub => sub {
my ($html_ref) = @_;
# ...
},
);
request_urls_iter
my $url = 'http://bbs.jjwxc.net/showmsg.php?board=153&id=57';
my ($info, $url_list) = $browser->request_urls_iter( $url,
#post_data => ...,
#min_page_num=> ...,
#max_page_num=> ...,
info_sub => sub {
my ($html_ref) = @_;
# ...
},
content_sub => sub {
my ($html_ref) = @_;
# ...
},
item_sub => sub {
my ($h) = @_;
# ...
},
next_url_sub => sub {
my ($start_url, $i, $html_ref) = @_;
# ...
},
#url_list_sub => sub {
# my ($html_ref) = @_;
# # ...
#},
stop_sub => sub {
my ($info, $data_list, $i, %o) = @_;
# ...
},
);
read_moz_cookie
#firefox sqlite3 : cookies.sqlite
$browser->read_moz_cookie($mozilla_cookies_sqlite_file, $domain);
#netscape http cookie file: cookie.txt
#same as: curl -b cookie.txt -c cookie.txt http://www.xxx.com
$browser->read_moz_cookie($netscape_http_cookie_file, $domain);
#cookie string: name1=value1; name2=value2
#same as: curl -b "name1=value1; name2=value2" http://www.xxx.com
$browser->read_moz_cookie($cookie_string, $domain);