Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
google-search-results-serpwow
Advanced tools
This Node.JS module allows you to scrape and parse Google Search Results using SerpWow. In addition to Search you can also use this package to access the SerpWow Locations API and Account API.
You can install google-search-results-serpwow with:
$ pip install google-search-results-serpwow
and upgrade with:
$ pip install google-search-results-serpwow --upgrade
We have included examples here but full SerpWow API documentation is available at the API Docs:
Simplest example for a standard query "pizza", returning the Google SERP (Search Engine Results Page) data as JSON:
from serpwow.google_search_results import GoogleSearchResults
import json
# create the serpwow object, passing in our API key
serpwow = GoogleSearchResults("demo")
# set up a dict for the search parameters
params = {
"q" : "pizza"
}
# retrieve the search results as JSON
result = serpwow.get_json(params)
# pretty-print the result
print json.dumps(result, indent=2, sort_keys=True)
To get a free API Key head over to app.serpwow.com/signup.
Example of a Google query geo-locating the query as if the user were located in New York.
from serpwow.google_search_results import GoogleSearchResults
import json
# create the serpwow object, passing in our API key
serpwow = GoogleSearchResults("demo")
# set up a dict for the query (q) and location parameters
# note that the "location" parameter should be a value
# returned from the Locations API
params = {
"q" : "pizza",
"location" : "New York,New York,United States"
}
# retrieve the search results as JSON
result = serpwow.get_json(params)
# pretty-print the result
print json.dumps(result, indent=2, sort_keys=True)
Use the search_type
param to search Google Places, Videos, Images and News. See the Search API Parameters Docs for full details of the additional params available for each search type.
from serpwow.google_search_results import GoogleSearchResults
import json
# create the serpwow object, passing in our API key
serpwow = GoogleSearchResults("demo")
# perform a search on Google News, just looking at blogs, filtering out duplicates
params = {
"q" : "football news",
"search_type" : "news",
"news_type" : "blogs",
"show_duplicates" : "false"
}
result = serpwow.get_json(params)
print json.dumps(result, indent=2, sort_keys=True)
# perform a search on Google Places for "plumber" in London
params = {
"search_type" : "places",
"q" : "plumber",
"location" : "London,England,United Kingdom"
}
result = serpwow.get_json(params)
print json.dumps(result, indent=2, sort_keys=True)
# perform an image search on Google Images for "red flowers"
params = {
"q" : "red flowers",
"search_type" : "images"
}
result = serpwow.get_json(params)
print json.dumps(result, indent=2, sort_keys=True)
google-search-results-serpwow
can return data in JSON, HTML and CSV formats using the get_json
, get_html
and get_csv
methods. For CSV results use the csv_fields
param (docs) to request specific result fields.
from serpwow.google_search_results import GoogleSearchResults
import json
# create the serpwow object, passing in our API key
serpwow = GoogleSearchResults("demo")
# set up a dict for the query (q) and location parameters
# note that the "location" parameter should be a value
# returned from the Locations API
params = {
"q" : "pizza",
"location" : "New York,New York,United States"
}
# retrieve the search results as JSON
result_json = serpwow.get_json(params)
# retrieve the search results as HTML
result_html = serpwow.get_html(params)
# retrieve the search results as CSV
result_csv = serpwow.get_csv(params)
To request that SerpWow renders the Google search results via a mobile or tablet browser use the device
param:
from serpwow.google_search_results import GoogleSearchResults
import json
serpwow = GoogleSearchResults("demo")
# set up the mobile params
params_mobile = {
"q" : "pizza",
"device" : "mobile"
}
# set up the tablet params
params_tablet = {
"q" : "pizza",
"device" : "tablet"
}
# set up the desktop params (note we omit the "device" param)
params_desktop = {
"q" : "pizza"
}
# retrieve the mobile search results
result_mobile_json = serpwow.get_json(params_mobile)
# retrieve the tablet search results
result_tablet_json = serpwow.get_json(params_tablet)
# retrieve the desktop search results
result_desktop_json = serpwow.get_json(params_desktop)
When making a request via the get_json
method a standard Python dict
is returned. You can inspect this dict to iterate, parse and store the results in your app.
from serpwow.google_search_results import GoogleSearchResults
import json
# make a simple query, returning JSON
serpwow = GoogleSearchResults("demo")
result = serpwow.get_json({ "q" : "pizza" })
# determine if the request was successful
success = result["request_info"]
if success:
# extract the time taken and number of organic results
time_taken = result["search_metadata"]["total_time_taken"]
organic_result_count = len(result["organic_results"])
# print
print str(organic_result_count) + " organic results returned in " + str(time_taken) + "s"
Use the start
and num
parameters to paginate through Google search results. start
is 0-based. The maximum number of results returned per page (controlled by the num
param) is 100 (a Google-imposed limitation) for all search_type
's apart from Google Places, where the maximum is 20. Here's an example.
from serpwow.google_search_results import GoogleSearchResults
import json
# request the first 100 results
serpwow = GoogleSearchResults("demo")
params = {
"q" : "pizza",
"start" : 0,
"num": 100
}
result_page_1 = serpwow.get_json(params)
# request the next 100 results
params["start"] = 100
result_page_2 = serpwow.get_json(params)
# pretty-print the result
print "Page 1"
print json.dumps(result_page_1, indent=2, sort_keys=True)
print "Page 2"
print json.dumps(result_page_2, indent=2, sort_keys=True)
from serpwow.google_search_results import GoogleSearchResults
# create the serpwow object, passing in our API key
serpwow = GoogleSearchResults("demo")
# set up a dict for the search parameters
params = {
"q" : "pizza",
"search_type" : "images",
"gl" : "us",
"hl" : "en",
"location" : "New York,New York,United States",
"google_domain" : "google.com",
"time_period" : "custom",
"sort_by" : "date",
"time_period_min" : "02/01/2018",
"time_period_max" : "02/08/2019",
"device" : "mobile",
"csv_fields" : "search.q,organic_results.position,organic_results.domain",
"start" : "0",
"num" : "100"
}
# retrieve the search results as CSV
result = serpwow.get_csv(params)
print result
The Locations API allows you to search for SerpWow supported Google search locations. You can supply the full_name
returned by the Locations API as the location
parameter in a Search API query (see Searching with a location example above) to retrieve search results geo-located to that location.
from serpwow.google_search_results import GoogleSearchResults
import json
# create the serpwow object, passing in our API key
serpwow = GoogleSearchResults("demo")
# set up a dict for the location query parameters
params = {
"q" : "mumbai"
}
# retrieve locations matching the query parameters as JSON
result = serpwow.get_locations(params)
# pretty-print the result
print json.dumps(result, indent=2, sort_keys=True)
The Account API allows you to check your current SerpWow usage and billing information.
from serpwow.google_search_results import GoogleSearchResults
import json
# create the serpwow object, passing in our API key
serpwow = GoogleSearchResults("demo")
# get our account info
result = serpwow.get_account()
# pretty-print the result
print json.dumps(result, indent=2, sort_keys=True)
FAQs
Google Search Results Node JS API via SerpWow.com
The npm package google-search-results-serpwow receives a total of 11 weekly downloads. As such, google-search-results-serpwow popularity was classified as not popular.
We found that google-search-results-serpwow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.