-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
200 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/Parser/Evaluated/Rule/Natural/Classical/ClassicalCardsResultO9g5cc.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/** | ||
* @license see LICENSE | ||
*/ | ||
|
||
namespace Serps\SearchEngine\Google\Parser\Evaluated\Rule\Natural\Classical; | ||
|
||
use Serps\Core\Dom\DomElement; | ||
use Serps\Core\Dom\DomNodeInterface; | ||
use Serps\Core\Serp\BaseResult; | ||
use Serps\Core\Serp\IndexedResultSet; | ||
use Serps\SearchEngine\Google\NaturalResultType; | ||
use Serps\SearchEngine\Google\Page\GoogleDom; | ||
use Serps\SearchEngine\Google\Parser\ParsingRuleInterface; | ||
|
||
/** | ||
* First seen in august 2018 in mobile pages, replacing .ZINbbc | ||
*/ | ||
class ClassicalCardsResultO9g5cc implements ParsingRuleInterface | ||
{ | ||
|
||
public function match(GoogleDom $dom, DomElement $node) | ||
{ | ||
$res = $dom->cssQuery('.O9g5cc.xpd a.C8nzq', $node); | ||
// TODO consider removing .ZINbbc (replaced with .O9g5cc in august 2018) | ||
|
||
if ($res->length == 1) { | ||
return self::RULE_MATCH_MATCHED; | ||
} | ||
|
||
return self::RULE_MATCH_NOMATCH; | ||
} | ||
|
||
public function parse(GoogleDom $dom, \DomElement $node, IndexedResultSet $resultSet) | ||
{ | ||
$classicalData = $this->parseNode($dom, $node); | ||
|
||
$resultTypes = [NaturalResultType::CLASSICAL]; | ||
|
||
$item = new BaseResult($resultTypes, $classicalData); | ||
$resultSet->addItem($item); | ||
} | ||
|
||
protected function parseNode(GoogleDom $dom, DomNodeInterface $node) | ||
{ | ||
return [ | ||
'title' => function () use ($dom, $node) { | ||
return $dom | ||
->cssQuery('a .MUxGbd', $node) | ||
->getNodeAt(0) | ||
->getNodeValue(); | ||
}, | ||
'isAmp' => function () use ($dom, $node) { | ||
return $dom | ||
->cssQuery('.ZseVEf', $node) | ||
->length > 0; | ||
}, | ||
'url' => function () use ($dom, $node) { | ||
return $dom | ||
->cssQuery('a.C8nzq', $node) | ||
->getNodeAt(0) | ||
->getAttribute('href'); | ||
}, | ||
'destination' => function () use ($dom, $node) { | ||
return $dom | ||
->cssQuery('span.QHTnWc, span.qzEoUe', $node) // TODO ".QHTnWc" appears to be outdated | ||
->getNodeAt(0) | ||
->getNodeValue(); | ||
}, | ||
'description' => function () use ($dom, $node) { | ||
return $dom | ||
->cssQuery('.JTuIPc:not(a)>.MUxGbd', $node) | ||
->getNodeAt(0) | ||
->getNodeValue(); | ||
} | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
test/resources/pages-mobile/2018/08/new+construction+ct.html
Large diffs are not rendered by default.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
test/suites/Parser/Evaluated/natural-parser-data/mobile/2018/08/new-construction-ct.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# image-group recipes | ||
url: https://www.google.ca/search?q=new+construction+ct | ||
file: test/resources/pages-mobile/2018/08/new+construction+ct.html | ||
|
||
test-methods: | ||
javascriptIsEvaluated: true | ||
getNumberOfResults: null | ||
isMobile: true | ||
|
||
results: | ||
|
||
- types: | ||
- CLASSICAL | ||
|
||
data: | ||
title: Connecticut New Homes & New Construction For Sale | Zillow | ||
destination: Zillow › ct › new-homes | ||
url: https://www.zillow.com/ct/new-homes/ | ||
description: Discover new construction homes or master planned communities in Connecticut . Check out floor plans, pictures and ... | ||
|
||
- types: | ||
- CLASSICAL | ||
data: | ||
url: https://www.realtor.com/newhomesconstruction/Connecticut | ||
destination: Realtor.com › newhomesconstruction › C... | ||
|
||
- types: | ||
- CLASSICAL | ||
|
||
- types: | ||
- CLASSICAL | ||
|
||
- types: | ||
- CLASSICAL | ||
|
||
data: | ||
title: New Home Development and New Home Construction | William ... | ||
|
||
- types: | ||
- CLASSICAL | ||
|
||
- types: | ||
- CLASSICAL | ||
|
||
- types: | ||
- CLASSICAL | ||
|
||
- types: | ||
- CLASSICAL | ||
|
||
data: | ||
isAmp: true | ||
|
||
- types: | ||
- CLASSICAL | ||
|
||
data: | ||
isAmp: true | ||
title: Connecticut Homes for Sale - 13 New Home Communities | Toll ... | ||
url: https://www.tollbrothers.com/luxury-homes/Connecticut?amp=true | ||
destination: Toll Brothers › luxury-homes | ||
description: Connecticut homes for sale by Toll Brothers®. 13 new luxury home communities in CT. View photos, floor plans, pricing ... |