serp-spider / search-engine-google

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

wrong start value coming in the search url #27

Closed lmahesh5 closed 8 years ago

lmahesh5 commented 8 years ago

The search url for page 1 and 2 is coming fine, but from 3rd page the start value becomes huge. For example, page 1 : https://www.google.co.in/search?q=buy+watches&uule=w+CAIQICIHQ2hlbm5haQ&gws_rd=cr page 2 : https://www.google.co.in/search?q=buy+watches&start=10&uule=w+CAIQICIHQ2hlbm5haQ&gws_rd=cr page 3 : https://www.google.co.in/search?q=buy+watches&start=200&num=100&uule=w+CAIQICIHQ2hlbm5haQ&gws_rd=cr Here page 3 start value should be 20, but it shows 200. My inputs are page 1, results 10 / page 2, results 10 / page 3, results 100. So, ideally the 3rd url should be start=20&num=100

gsouf commented 8 years ago

Hi @lmahesh5

Did you set 100 results per pages? In your example with third page you have num=100 that means that for page 3 start = 200

Can you confirm that?

lmahesh5 commented 8 years ago

Hi @gsouf I have set the page number and number of results per page as below for 3 iterations. (1) Page no : 1, number of results per page 10 (2) Page no : 2, number of results per page 10 (3) Page no : 3, number of results per page 100.

The purpose is to get page 1 with 1 to 10 results and page 2 with 11 to 20 results and page 3 with 21 to 120 results.

gsouf commented 8 years ago

@lmahesh5 that's the expected behavior of GoogleUrl::setPage. It automically sets the page according to the number of results per page. In your case it sets the third page for 100 results per page. What you have to do to workaround it is to use setParam to manually set the start parameter of the url:

$url->setResultsPerPage(100);
$url->setParam('start', 30);
lmahesh5 commented 8 years ago

ok @gsouf thanks