j0k3r / graby

Graby helps you extract article content from web pages
MIT License
365 stars 74 forks source link

Error: Call to a member function saveXML() on null #333

Open kolaente opened 1 year ago

kolaente commented 1 year ago

I'm trying to run Graby like this:

$graby = new Graby();
$graby->fetchContent('http://www.bbc.com/news/entertainment-arts-32547474');

it fails with this error:

Error: Call to a member function saveXML() on null
/opt/project/vendor/j0k3r/graby/src/Extractor/ContentExtractor.php:163
/opt/project/vendor/j0k3r/graby/src/Graby.php:318
/opt/project/vendor/j0k3r/graby/src/Graby.php:136
/opt/project/tests/Feature/HttpCrawlTest.php:39

I dug in a little, and it seems like the $dom property of the Readability class never gets initialized. I wonder why that is the case?

I'm using php 8.2 with the changes from #332.

jtojnar commented 1 year ago

Maybe look at https://github.com/j0k3r/graby/pull/286, it moves the init function.

kolaente commented 1 year ago

That works! Thanks!