Git Product home page Git Product logo

novel-robot-browser's Introduction

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 $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) = @_; 
            # ...
        }, 
        );
#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);

novel-robot-browser's People

Contributors

abbypan avatar manwar avatar

Watchers

 avatar

Forkers

manwar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.