I need click a button 'Vew more' in my page, but not is a form, is a button type "button".
My code's look:
$client = new Client();
$crawler = $client->request('GET', 'https://www.xxxx.com');
$button = $crawler->selectButton('View more');
$client->click($button);
This returns:
Catchable fatal error: Argument 1 passed to Symfony\Component\BrowserKit\Client::click() must be an instance of Symfony\Component\DomCrawler\Link, instance of Symfony\Component\DomCrawler\Crawler given, called in C:\xampp\htdocs\scrapper\index.php on line 17 and defined in C:\xampp\htdocs\scrapper\vendor\symfony\browser-kit\Client.php on line 238
Any ideas? :(
As per the documentation:
A selectButton() method is available on the Crawler which returns another Crawler that matches a button (input[type=submit], input[type=image], or a button) with the given text.
Actually, that is what the error is saying: the parameter received by click()
is a crawler
, when it should be a Link
. I'm not familiar with goutte scrapper, but have you tried with:
$button = $crawler->selectButton('View more')->button();
$client->click($button);