I want to do some Google searches and get the same result as I would search on www.google.se (I'm in Sweden). I've created a Google API account to get an API key here, https://code.google.com/apis/console/b/0/.
I call the API like this:
https://www.googleapis.com/customsearch/v1?key=KEY&cx=013036536707430787589:_pqjad5hr1a&gl=se&cr=se&googlehost=google.se&q=bästa espressomaskin&alt=json
However this gives different results from searching on "bästa espressomaskin" like I normally would, and I can't figure out why.
The second question I have is about the parameter "cx". What is it actually and what does it do? I just used the one provided at the Google API introduction site.
I also want more than 10 results, my API Console account has some dollars on it, but how do I make it possible to set my "num"-parameter to more than 10?
Thanks
The Search Console API provides programmatic access to the most popular reports and actions in your Search Console account. Query your search analytics, list your verified sites, manage your sitemaps for your site, and more. Official Google Search updates and SEO best practices.
When you search on Google, you may find thousands or even millions of matching web pages. The most relevant results are displayed first. To find more web results, click Next or More Results at the bottom of the search results page.
Start using the API — It's free! Our powerful cloud infrastructure is built to withstand high volume API requests without the need of a queue.
GET YOUR GOOGLE SEARCH API KEY Accessing Google's Custom Search JSON API requires the use of an API key. To get this key, navigate to the Custom Search JSON API page and click Get a Key. Choose an existing project, or create a new one, and click Next. Note and copy your API key.
cx is the Google key you get for signing up for their custom search service. It allows you to customize your search. See here for more information: https://developers.google.com/custom-search/v1/getting_started
As for results, Google says in their documentation that your results may vary. See here for more information: http://support.google.com/customsearch/bin/answer.py?hl=en&answer=2633385
You can use SerpApi to access extracted data from regular Google search results.
Example of using it with curl
.
curl -s 'https://serpapi.com/search?q=coffee&location=Sweden&google_domain=google.se&gl=se&hl=sv&num=100'
Here's an example of using it via the google-search-results
package.
from serpapi import GoogleSearch
import os
params = {
"engine": "google",
"q": "coffee",
# "q": "bästa espressomaskin",
"location": "Sweden",
"google_domain": "google.se",
"gl": "se",
"hl": "sv",
"num": 100,
"api_key": os.getenv("API_KEY")
}
client = GoogleSearch(params)
data = client.get_dict()
print("Organic results")
for result in data['organic_results']:
print(f"""
Title: {result['title']}
Link: {result['link']}
Position: {result['position']}
Snippet: {result['snippet']}
""")
Check other extracted data on SerpApi playground or in the documentation.
Disclaimer: I work at SerpApi.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With