Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting NULL on $page->content() #17

Open
RobinDev opened this issue Dec 14, 2024 · 6 comments
Open

Getting NULL on $page->content() #17

RobinDev opened this issue Dec 14, 2024 · 6 comments

Comments

@RobinDev
Copy link

RobinDev commented Dec 14, 2024

Describe the bug

Getting NULL on $page->content() randomly : on a few websites, it's working, on others not.

Reproducible example

I try with a blank new installation

<?php

use Nesk\Puphpeteer\Puppeteer;

include 'vendor/autoload.php';

$url = 'https://www.nytimes.com/international/';
$puppeteer = new Puppeteer();
$browser = $puppeteer->launch();
$page = $browser->newPage();
$page->goto($url);
var_dump($page->content());

When i set headless false, i can see the page is correctly loaded.

Generated logs

When i try to log it, i get :

Execution context was destroyed, most likely because of a navigation.

Environment (please complete the following information):

  • OS: Ubuntu 24.04
  • Node version:20.11
  • PHP version 8.3.14

My Node package manager is:

  • NPM 10.9.2
@RobinDev
Copy link
Author

When i try directly with puppeteer, it's working :

import puppeteer from "puppeteer";

const browser = await puppeteer.launch({});
const page = await browser.newPage();

await page.goto("https://www.nytimes.com/international/");
console.log(await page.content());

await browser.close();

@Raja-Omer-Mustafa
Copy link

Raja-Omer-Mustafa commented Dec 17, 2024

I am facing the same null issue if data is too large I am getting a JSON from a page.
I beleive if size of Data increase it returns null

$responseJson = $page->evaluate(
    JsFunction::createWithBody(
        "
        if (document.querySelector('pre'))
        {
            return document.querySelector('pre').innerHTML;
        }
        return false
        "
    )
);

@RobinDev
Copy link
Author

RobinDev commented Dec 17, 2024

OK, thank you for your message.

I think it's not Puphpeteer or Rialto bug but more a terminal buffer size wich change after an update.

I face the same problem you describe developping a direct wrapper for a puppeteer script... my workaround was to store the terminal output in a file.

So it should be quicker to find, change and test the OS buffer param for terminal.

@RobinDev
Copy link
Author

Try some stuff but without success, still getting null.

@Raja-Omer-Mustafa
Copy link

I also Increase memory_limit on php.ini and Node limit but still same
@RobinDev might be resources issue. can you help share your specs because the same code works for me on Ubuntu Instance.
I am facing issue on my Development Laptop.

@pich
Copy link

pich commented Dec 28, 2024

I'm facing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants