Skip to content

Commit

Permalink
fix related searches selector
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Sep 4, 2023
1 parent 5710c54 commit ba972d4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results
@@ -1 +1 @@
{"version":1,"defects":{"GoogleSerpTest::testPuphpeteerMobile":8,"GoogleSerpTest::testCurlMobile":8,"GoogleSerpTest::testExtractionPositionZero":8,"GoogleSerpTest::testExtractMaps":8},"times":{"PiedWeb\\Crawler\\Test\\CrawlerTest::testIt":0.968,"PiedWeb\\Crawler\\Test\\CrawlerTest::testCommand":0.324,"PiedWeb\\Crawler\\Test\\CrawlerTest::testWitchCachId":0.627,"PiedWeb\\Curl\\Test\\HelperTest::testSchemeFromProxy":0,"PiedWeb\\Curl\\Test\\HelperTest::testCheckContentType":0,"PiedWeb\\Curl\\Test\\HelperTest::testCheckStatusCode":0,"PiedWeb\\Curl\\Test\\RequestTest::testDownloadIfHtml":0.304,"PiedWeb\\Curl\\Test\\RequestTest::testNotDownload":0.205,"PiedWeb\\Curl\\Test\\RequestTest::testEffectiveUrl":20.512,"PiedWeb\\Curl\\Test\\RequestTest::testCurlError":0.042,"PiedWeb\\Curl\\Test\\RequestTest::test404":0.264,"PiedWeb\\Curl\\Test\\RequestTest::testAllMethods":0.177,"PiedWeb\\Curl\\Test\\RequestTest::testMultipleCheckInHeaders":0.122,"PiedWeb\\Curl\\Test\\RequestTest::testProxy":1.002,"PiedWeb\\Curl\\Test\\RequestTest::testAbortIfTooBig":5.267,"PiedWeb\\Curl\\Test\\RequestTest::testDownloadOnlyFirstBytes":0.198,"PiedWeb\\Curl\\Test\\RequestTest::testResponseFromCache":0,"PiedWeb\\Curl\\Test\\StaticWrapperTest::testStaticGet":0.161,"GlobalTest::testEncoding":0.002,"GlobalTest::testCanonical":0.673,"GlobalTest::testTextDataExtractor":0.417,"GlobalTest::testHrefLangExtractor":0.657,"GoogleSerpTest::testPuphpeteerMobile":2.643,"GoogleSerpTest::testCurlMobile":0.596,"GoogleSerpTest::testExtractionPositionZero":0.685,"GoogleSerpTest::testExtractMaps":0.508,"GoogleSuggesterTest::testGoogleSuggester":1.482,"GoogleTrendsTest::testTrendsCurl":0.002,"GoogleTrendsTest::testTrendsPuppet":0.002,"PiedWeb\\TextAnalyzer\\Test\\AnalyzerTest::testMultiAnalyzer":0.021,"PiedWeb\\TextAnalyzer\\Test\\AnalyzerTest::testTextAnalyzer":0.008,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testSimpleSentences":0.001,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveExtremityStopWords":0.001,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveExtremityStopWords2":0.001,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveStopWords":0.001,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testStripTags":0.002}}
{"version":1,"defects":{"GoogleSerpTest::testPuphpeteerMobile":8,"GoogleSerpTest::testCurlMobile":8,"GoogleSerpTest::testExtractionPositionZero":8,"GoogleSerpTest::testExtractMaps":8,"GlobalTest::testTextDataExtractor":7},"times":{"PiedWeb\\Crawler\\Test\\CrawlerTest::testIt":25.741,"PiedWeb\\Crawler\\Test\\CrawlerTest::testCommand":0.242,"PiedWeb\\Crawler\\Test\\CrawlerTest::testWitchCachId":0.343,"PiedWeb\\Curl\\Test\\HelperTest::testSchemeFromProxy":0,"PiedWeb\\Curl\\Test\\HelperTest::testCheckContentType":0,"PiedWeb\\Curl\\Test\\HelperTest::testCheckStatusCode":0,"PiedWeb\\Curl\\Test\\RequestTest::testDownloadIfHtml":0.404,"PiedWeb\\Curl\\Test\\RequestTest::testNotDownload":0.261,"PiedWeb\\Curl\\Test\\RequestTest::testEffectiveUrl":21.524,"PiedWeb\\Curl\\Test\\RequestTest::testCurlError":0.048,"PiedWeb\\Curl\\Test\\RequestTest::test404":0.245,"PiedWeb\\Curl\\Test\\RequestTest::testAllMethods":0.228,"PiedWeb\\Curl\\Test\\RequestTest::testMultipleCheckInHeaders":0.12,"PiedWeb\\Curl\\Test\\RequestTest::testProxy":1.002,"PiedWeb\\Curl\\Test\\RequestTest::testAbortIfTooBig":20.27,"PiedWeb\\Curl\\Test\\RequestTest::testDownloadOnlyFirstBytes":0.218,"PiedWeb\\Curl\\Test\\RequestTest::testResponseFromCache":0,"PiedWeb\\Curl\\Test\\StaticWrapperTest::testStaticGet":0.164,"GlobalTest::testEncoding":0.109,"GlobalTest::testCanonical":0.643,"GlobalTest::testTextDataExtractor":0.233,"GlobalTest::testHrefLangExtractor":0.657,"GoogleSerpTest::testPuphpeteerMobile":2.643,"GoogleSerpTest::testCurlMobile":0.596,"GoogleSerpTest::testExtractionPositionZero":0.685,"GoogleSerpTest::testExtractMaps":0.508,"GoogleSuggesterTest::testGoogleSuggester":1.482,"GoogleTrendsTest::testTrendsCurl":0.002,"GoogleTrendsTest::testTrendsPuppet":0.002,"PiedWeb\\TextAnalyzer\\Test\\AnalyzerTest::testMultiAnalyzer":0.021,"PiedWeb\\TextAnalyzer\\Test\\AnalyzerTest::testTextAnalyzer":0.008,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testSimpleSentences":0.001,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveExtremityStopWords":0.001,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveExtremityStopWords2":0.001,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testRemoveStopWords":0.001,"PiedWeb\\ExpressionHarvester\\Test\\CleanTextTest::testStripTags":0.002,"GoogleSerpTest::testRelatedSearches":0.496}}
2 changes: 1 addition & 1 deletion packages/extractor/tests/GlobalTest.php
Expand Up @@ -96,7 +96,7 @@ public function testTextDataExtractor(): void

$this->assertSame('title', array_values($textData->getFlatContent())[0]);
$this->assertGreaterThan(10, $textData->getWordCount());
$this->assertGreaterThan(10, $textData->getRatioTxtCode());
$this->assertGreaterThan(8, $textData->getRatioTxtCode());
// dump($textData->getTextAnalysis()->getExpressions(2));
$this->assertArrayHasKey('web', $textData->getTextAnalysis()->getExpressions());
}
Expand Down
2 changes: 1 addition & 1 deletion packages/google/src/Extractor/SERPExtractor.php
Expand Up @@ -24,7 +24,7 @@ class SERPExtractor
/**
* @var string[]
*/
final public const RELATED = ["//a[@data-xbu][starts-with(@href, '/search')]/div/div/span"];
final public const RELATED = ['//span[text()="Recherches associées"]/ancestor::*[position() < 5]//a/div/div/span'];

/**
* @var string[]
Expand Down
10 changes: 10 additions & 0 deletions packages/google/tests/GoogleSerpTest.php
Expand Up @@ -90,4 +90,14 @@ public function testExtractMaps(): void
$mapsResults = $extractor->extractBusinessResults();
$this->assertArrayHasKey(0, $mapsResults);
}

public function testRelatedSearches(): void
{
$extractor = $this->getExtractor('randonnée valgaudemar');

$extractor->getBrowserPage()->screenshot(['path' => 'debug.png']);

$relatedSearches = $extractor->getRelatedSearches();
$this->assertContains('Rando Valgaudemar 3 jours', $relatedSearches);
}
}

0 comments on commit ba972d4

Please sign in to comment.