WWW::Mechanize之后小结
时间:2009-03-25 来源:snowtty
-
CONSTRUCTOR AND STARTUP
- new()
- $mech->agent_alias( $alias )
- known_agent_aliases()
-
PAGE-FETCHING METHODS
- $mech->get( $uri )
- $mech->put( $uri, content => $content )
- $mech->reload()
- $mech->back()
-
STATUS METHODS
- $mech->success()
- $mech->uri()
- $mech->response() / $mech->res()
- $mech->status()
- $mech->ct() / $mech->content_type()
- $mech->base()
- $mech->forms()
- $mech->current_form()
- $mech->links()
- $mech->is_html()
- $mech->title()
-
CONTENT-HANDLING METHODS
- $mech->content(...)
-
LINK METHODS
- $mech->links
- $mech->follow_link(...)
- $mech->find_link( ... )
- $mech->find_all_links( ... )
- $mech->find_all_inputs( ... criteria ... )
- $mech->find_all_submits( ... criteria ... )
-
IMAGE METHODS
- $mech->images
- $mech->find_image()
- $mech->find_all_images( ... )
-
FORM METHODS
- $mech->forms
- $mech->form_number($number)
- $mech->form_name( $name )
- $mech->form_id( $name )
- $mech->form_with_fields( @fields )
-
FIELD METHODS
- $mech->field( $name, $value, $number )
- $mech->field( $name, \@values, $number )
- $mech->select($name, $value)
- $mech->select($name, \@values)
- $mech->set_fields( $name => $value ... )
- $mech->set_visible( @criteria )
- $mech->tick( $name, $value [, $set] )
- $mech->untick($name, $value)
- $mech->value( $name, $number )
- $mech->click( $button [, $x, $y] )
- $mech->click_button( ... )
- $mech->submit()
- $mech->submit_form( ... )
-
MISCELLANEOUS METHODS
- $mech->add_header( name => $value [, name => $value... ] )
- $mech->delete_header( name [, name ... ] )
- $mech->quiet(true/false)
- $mech->stack_depth( $max_depth )
- $mech->save_content( $filename )
- $mech->dump_links( [[$fh], $absolute] )
- $mech->dump_images( [[$fh], $absolute] )
- $mech->dump_forms( [$fh] )
- $mech->dump_all( [[$fh], $absolute] )
-
OVERRIDDEN LWP::UserAgent METHODS
- $mech->clone()
- $mech->redirect_ok()
- $mech->request( $request [, $arg [, $size]])
- $mech->update_html( $html )
- $mech->credentials( $username, $password )
- $mech->get_basic_credentials( $realm, $uri, $isproxy )
- $mech->clear_credentials()
-
INTERNAL-ONLY METHODS
- $mech->_update_page($request, $response)
- $mech->_modify_request( $req )
- $mech->_make_request()
- $mech->_reset_page()
- $mech->_extract_links()
- $mech->_push_page_stack()
- warn( @messages )
- die( @messages )
用了一下这个模块.感觉还是比较方便的.对于模拟browse实现以下功能:
$mech->set_visible() 可以实现登陆功能.
$mech->dump_all 可以得出网页一个大概面貌,然后结合firefox的页面属性,可以实现post表单.
$mech->save_content() 可以保存网页内容到一个文件.
$mech->ct() 可以看到服务器返回的类型,是text/html或者是application的.之前有一个页面的meta里有一个refresh,我就用到了这个子程序
$mech->submit_form() 可以提交网页内容到服务器.
相关阅读 更多 +