首页 > 解决方案 > 如何在外部网站上使用 Panther 登录?

问题描述

我使用 symfony/panther 进行网络爬取。要访问我想要的页面,我需要经过身份验证,但我不知道该怎么做。

我努力了 :

$client = Client::createChromeClient();
$client->start();
$crawler = $client->request('GET', 'http://website.com/login.php');

$form = $crawler->selectButton('Submit!')->form([
    'email' => myEmail,
    'pwd'   => myPassword
]);
$client->submit($form);

但它不起作用,我的用户没有经过身份验证。

我想我需要检索一个 cookie 并将其添加到我的客户端,但我不知道该怎么做。有人可以给我执行此操作的步骤吗?

标签: symfony-panther

解决方案


推荐阅读