serp-spider / search-engine-google

:spider: Google client for SERPS
https://serp-spider.github.io
Other
168 stars 61 forks source link

How to use NaturalResults Parser with Google SERP scraped with Curl #107

Closed puneetas3 closed 6 years ago

puneetas3 commented 6 years ago

I am scraping Google search with another script/code as a curl request (its integrated with proxies, UA etc). How can I feed the response of curl request (google.com search page) to NaturalResults for further processing?

Is there a method to use string (curl response) with getNaturalResults(); Thanks.

gsouf commented 6 years ago

Hi @puneetas3

You can do the following:

use Serps\SearchEngine\Google\Page\GoogleSerp;
use Serps\Core\Url;

$urlOfTheGooglePage = GoogleUrl::fromString('http://google.com/search?q=.....');
$htlmOfTheGooglePageYouParsed = '<html>.......';

$serp = new GoogleSerp($htlmOfTheGooglePageYouParsed, $urlOfTheGooglePage);

$serp->getNaturalResults();