I'm trying the chrome-php/chrome library to read dynamically rendered web pages, but it's not returning anything. I'm using php version 8.0.
This is what I have implemented [I have followed the documentation] -
use HeadlessChromium\BrowserFactory; $browserFactory = new BrowserFactory(); // starts headless chrome $browser = $browserFactory->createBrowser('/opt/google/chrome/chrome'); try { // creates a new page and navigate to an URL $page = $browser->createPage(); $page->navigate('http://example.com')->waitForNavigation(); // get page title $pageTitle = $page->evaluate('document.title')->getReturnValue(); echo $pageTitle; } finally { //bye $browser->close(); }
It's not returning the title of the URL I'm trying to read. Can you help me debug this issue?
Before making modifications, put this in your script so that it displays the error:
The error may lie in this line: This method does not accept strings.
You must pass the google chrome executable to:
Or leave it blank and the system will use the default location: