Configure SerpApi search parameters
masterYou can control your search using a dictionary of parameters passed to the GoogleSearch class. Common parameters include:
q: The search query.location: The location for the search.device: The device type (desktop,mobile, ortablet).hl: Google UI language.gl: Google country.safe: Safe Search flag.num: Number of results.start: Pagination offset.api_key: Your SerpApi key.tbm: Search type (e.g.,nwsfor news,ischfor images,shopfor shopping).tbs: Custom search criteria.async: Set totrueorfalseto enable/disable asynchronous requests.output: Output format (jsonorhtml).
You can also override parameters after initialization by modifying the search.params_dict dictionary.
params = {
"q": "coffee",
"location": "Location Requested",
"device": "desktop|mobile|tablet",
"hl": "Google UI Language",
"gl": "Google Country",
"safe": "Safe Search Flag",
"num": "Number of Results",
"start": "Pagination Offset",
"api_key": "Your SerpApi Key",
"tbm": "nws|isch|shop",
"tbs": "custom to be search criteria",
"async": "true|false",
"output": "json|html"
}
search = GoogleSearch(params)
# override an existing parameter
search.params_dict["location"] = "Portland"