Answer the question
In order to leave comments, you need to log in
How to set up parsing with a headless browser?
<?php
require 'phpQuery.php';
require_once('vendor/autoload.php');
use HeadlessChromium\BrowserFactory;
use HeadlessChromium\Input\Mouse;
use HeadlessChromium\Communication\Connection;
use HeadlessChromium\Communication\Message;
$browserFactory = new BrowserFactory("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe");
// starts headless chrome
$browser = $browserFactory->createBrowser([
'headless' => false, // disable headless mode
'windowSize' => [1920, 1000],
'enableImages' => false,
'sendSyncDefaultTimeout' => 30000000,
'userDataDir' => 'C:\Users\rusya\Downloads\ospanel\domains\localhost\fbparser\www',
'mouse' => false // will enable verbose mode
]);
$page = $browser->createPage();
$uri = 'https://www.facebook.com/groups/websarafan.ru/';
$page->navigate($uri)->waitForNavigation();
$evaluation = $page->evaluate('document.documentElement.innerHTML')->getReturnValue();
$doc = phpQuery::newDocument($evaluation);
$posts = $doc->find('.u_0_1m');
$browser->close();
echo $posts->length;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question