如何通过 QueryList 实现自动登录、签到等功能 [ 新手入门 ]
这里 QueryList 用的是最新版本的,与之前旧版本的写法有点差异
composer require jaeger/querylist
安装最新的代码
以 yiichina 为例:
use QL\QueryList;
//登录
$url = 'https://www.yiichina.com/login';
$loginPage = QueryList::get($url);
$_csrf = $loginPage->find('input[name="_csrf"]')->attr('value');
$postData = [
'_csrf' => $_csrf,
'LoginForm[username]' => 'aliang@qq.com',
'LoginForm[password]' => 'aliang123',
'LoginForm[rememberMe]' => '1',
];
QueryList::post($url, $postData)->getHtml();
//签到
$loginPage2 = QueryList::get('https://www.yiichina.com/');
$_csrf2 = $loginPage2->find('meta[name="csrf-token"]')->attr('content');
QueryList::post('https://www.yiichina.com/ajax/registration', ['_csrf' => $_csrf2])->getHtml();
//发表说说
$sspost = [
'_csrf' => $_csrf2,
'Feed[content]' => 'PHP是世界上最好的语言',
];
QueryList::post('https://www.yiichina.com/', $sspost)->getHtml();
共 0 条回复
没有找到数据。
胡歌 作品:《六月的雨》
注册时间:2021-11-06
最后登录:2025-08-15
在线时长:1611小时4分
最后登录:2025-08-15
在线时长:1611小时4分
- 粉丝5
- 金钱13610
- 威望0
- 积分29720