Get Google Search Results (python)
SERP API to scrape Google search results using Olostep and a Python code snippet.
Overview
Olostep’s API allows you to extract structured data from search engine results by using parsers. These parsers transform the raw HTML of search results into clean, structured JSON data that’s ready for analysis or integration into your applications.
Integration Example
To get parsed JSON content from search results, you need to include parser_extract
in the formats
parameter and specify the name of the parser @olostep/google-search
in the parser_extract
object.
Here’s how to retrieve Google search results in a structured format:
Response Format
When you make a request to the Olostep API with the Google Search parser, you’ll receive a JSON response like the example below:
The response contains:
- Basic request information:
id
,object
,created
timestamp,url_to_scrape
- Result object with URLs to access different formats of the data
- json_content with structured search results including:
searchParameters
: Information about the search queryknowledgeGraph
: Detailed information about the search subject (when available)organic
: List of search results with title, link, position, and snippetpeopleAlsoAsk
: Related questions that users commonly search forrelatedSearches
: Suggested related search queries
json_content
is the main part of the response with the structured search results. You can access the JSON content directly from the response or use the hosted URL provided in the response.
Structured Response: json_content
Olostep provides also a hosted JSON file with the structured search results. You can access the JSON file using the json_hosted_url
field in the response:
- Structured JSON: View example JSON
If you want to also get the HTML and Markdown content of the search results, you can include these formats in the formats
parameter and Olostep will return them in the response and provide hosted URLs for each format.
Important Notes
Search Parameters: The gl=us
and hl=en
parameters set the geolocation to US and language to English. Adjust these as needed.
Conclusion
Passing custom parsers to the API allows you to only get the structured data you want. This makes it easy to integrate search results into your applications, perform data analysis, or build search-related features.
To get information about available parsers or to request a custom parser for your specific use case, please contact us at info@olostep.com.