Closed LunarDevelopment closed 6 years ago
Also just stumbled on this one when using the following UA:
$userAgent = "Mozilla/5.0 (Android 7.0; Mobile; rv:54.0) Gecko/54.0 Firefox/54.0";
Serps\SearchEngine\Google\Exception\InvalidDOMException: Raw dom is not supported, please provide an evaluated version of the dom Google DOM has possibly changed and an update may be required. in /Users/directory/Projects/directory/directory/directory/vendor/serps/search-engine-google/src/Page/GoogleSerp.php:47
Hi @LunarDevelopment
I was already reported the first issue and didn't find how to reproduce it. Didn't think about mobile results, that I'm currently getting issues with as well. Will be working to get it fixed.
For the second issue the reason is that you are using an outdated user agent and google is responding with its "legacy" version that serps does not support anymore.
Thanks for coming back to me so quickly, and p.e. I love your libraries, bravo.
I've dug about and if I comment out the following then the script will run, but I get no NaturalResultType::CLASSICAL
to iterate through, so I'm guessing all I've done is remove the classes which parse results.
/**
* Parses natural results from a mobile google SERP
*/
class MobileNaturalParser extends AbstractParser
{
/**
* @inheritdoc
*/
protected function generateRules()
{
return [
new Divider(),
new SearchResultGroup(),
// new ClassicalCardsResultZ1m(),
new ClassicalCardsResult(),
// new TweetsCarouselZ1m(),
new ImageGroupCarousel(),
new ComposedTopStories(),
new VideoGroup(),
new ImageGroup(),
new PeopleAlsoAsk(), // people also ask must be placed before knowledge card to stop parsing
new KnowledgeCard()
];
}
/**
* @inheritdoc
*/
protected function getParsableItems(GoogleDom $googleDom)
{
$xpathObject = $googleDom->getXpath();
$xpathElementGroups = "//div[@id = 'ires']/*[@id = 'rso']/*";
return $xpathObject->query($xpathElementGroups);
}
}
Thanks for the details. If you have a little time to help me fixing this issue, then there is something you can do for me.
That would be to send me a copy of the dom that fails to parse (add is as an attachment in a message of this thread).
Details to save the dom are available here: https://serp-spider.github.io/documentation/search-engine/google/parse-page/#manipulate-the-dom-object
Here you go :
Hello again, is there a rough fix timescale or workaround on this issue?
Do you have a working mobile UA string ?
Hi @LunarDevelopment
Here is a modern mobile UA string:
Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1
Unfortunately I cannot you give you further details, I will be short in time this week, but will fix it as soon as possible.
Thanks for the suggestion, I've tested the UA string:
Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1
And am still getting :
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Call to undefined method DOMCdataSection::hasClass()
Do you get the same ?
Hi @LunarDevelopment
Not sure yet, I'll address this in the next few days now
I don't believe this library handles Google mobile results in the current incantation, I'd suggest removing the function and narrowing the scope of the library unless there's more contributors come on board to implement.
Closing this issue for now,
@LunarDevelopment mobile parsing is used in production environment with success
Hello,
When I use a mobile ua I get the below exception, is this an issue with parsing mobile pages in general or something I'm doing wrong..? example ua which produces the error:
/serps/search-engine-google/src/Parser/Evaluated/Rule/Natural/Classical/ClassicalCardsResultZ1m.php