Athlon1600 / SerpScraper

:mag_right: Google/Bing search results scraping using PHP. Tested and working / May 13, 2020
93 stars 38 forks source link

Customizable preferences #11

Closed kjellberg closed 1 year ago

kjellberg commented 8 years ago

Added the possibility to change more query string parameters

kjellberg commented 8 years ago

Would love to get some feedback on this commit. I really need it for my production server ASAP :)

@Athlon1600

Athlon1600 commented 8 years ago

This is not a bad idea but the implementation of it is what's bothering me. First of all, those query parameters keep changing every few months anyways. What gbv=1 means today, may not mean the same 3 months from now. And how is a person supposed to remember them all and what happens when they change? Code like this:

$google->setPreference('gbv', 1);

would break once Google replaces gbv with some other name or even splits the functionality into two variables. But if let's say you had:

$google->enableJavascript(false);

that would not break assuming you change the code inside "enableJavascript" function. But that would make it just as ugly. A MUCH BETTER solution would be to add a new "preference" named "query_params" that would let any user override any search param they want:

$override = array(
'q' => 'new_query',
'gbv' => 0
);

$google->setPreference('query_params', $override);

and this whole functionality could be added with just one line of code like this:
https://github.com/Athlon1600/SerpScraper/commit/abb71d547890e779c1690283802d55f3e5285507

Would this work?

kjellberg commented 8 years ago

Yeah, cool, you're absolutely right! And with your code its possible to add more query params (Y)

The most important thing for me was the possibility to change language.