Login simulated login extension


Login Simulated login extension

Login extension can simulate login and then collect it.

Installation:

composer require jaeger/querylist-ext-login

GIT address:

https://github.com/jae-jae/QueryList-Ext-Login.git

Dependencies (please ignore those installed through Composer)

Login extension depends on Request extension, Request extensionInstallation tutorial: http://doc.querylist.cc/site/index/doc/21

Usage

$login = QueryList::run('Login',[
    'target' => '登陆表单提交的目标地址',
    'method' => 'post',
    //登陆表单需要提交的数据
    'params' => ['username'=>'admin','password'=>'admin'],
    'cookiePath' => 'cookie保存路径'
    //更多参数查看Request扩展
    ]);
//登陆成功后,就可以调用get和post两个方法来抓取登陆后才能抓的页面
$ql = $login->get('页面地址'[,'处理页面的回调函数','传给回调的参数']);
$ql = $login->post('页面地址','post提交的数据数组'[,'处理页面的回调函数','传给回调的参数']);
$data = $ql->setQuery(...)->data;

The return value is the Login plug-in object. The return value of the get and post methods of this object is the QueryList object with the html attribute set, and then it should be called The setQuery method of QueryList sets the collection rules.

//模拟登陆
$login = QueryList::run('Login',[
    'target' => 'http://xxx.com/login',
    'method' => 'post',
    'params' => ['username'=>'admin','password'=>'admin'],
    'cookiePath' => './cookie123.txt'
    ]);
$data = $login->post('http://xxx.com/admin',['key'=>'value'],function($content,$args){
//这里可以对页面做一些格外的处理
//替换页面的所有的yyy为xxx
$content = str_replace('yyy',$args,$content);
return $content;
},'xxx')->setQuery(['title'=>['h1','text']])->data;