Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

a Python client library for SerpApi.

License

NotificationsYou must be signed in to change notification settings

serpapi/serpapi-python

Repository files navigation

This repository is the home of thesoon–to–be official Python API wrapper forSerpApi. Thisserpapi module allows you to access search data in your Python application.

SerpApi supports Google, Google Maps, Google Shopping, Bing, Baidu, Yandex, Yahoo, eBay, App Stores, and more. Check out thedocumentation for a full list.

Installation

To install theserpapi package, simply run the following command:

$ pip install serpapi

Please note that this package is separate from the legacyserpapi module, which is available on PyPi asgoogle-search-results. This package is maintained by SerpApi, and is the recommended way to access the SerpApi service from Python.

Usage

Let's start by searching for Coffee on Google:

>>>import serpapi>>> s= serpapi.search(q="Coffee",engine="google",location="Austin, Texas",hl="en",gl="us")

Thes variable now contains aSerpResults object, which acts just like a standard dictionary, with some convenient functions added on top.

Let's print the first result:

>>> s["organic_results"][0]["link"]'https://en.wikipedia.org/wiki/Coffee'

Let's print the title of the first result, but in a more Pythonic way:

>>> s["organic_results"][0].get("title")'Coffee - Wikipedia'

TheSerpApi.com API Documentation contains a list of all the possible parameters that can be passed to the API.

Documentation

Documentation isavailable on Read the Docs.

Basic Examples in Python

Search Bing

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'bing','q':'coffee'})

Search Baidu

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'baidu','q':'coffee',})

Search Yahoo

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'yahoo','p':'coffee',})

Search YouTube

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'youtube','search_query':'coffee',})

Search Walmart

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'walmart','query':'coffee',})

Search eBay

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'ebay','_nkw':'coffee',})

Search Naver

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'naver','query':'coffee',})

Search Home Depot

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'home_depot','q':'table',})

Search Apple App Store

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'apple_app_store','term':'coffee',})

Search DuckDuckGo

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'duckduckgo','q':'coffee',})

Search Google

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google','q':'coffee'})

Search Google Scholar

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_scholar','q':'coffee',})

Search Google Autocomplete

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_autocomplete','q':'coffee',})

Search Google Product

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_product','q':'coffee','product_id':'4887235756540435899',})

Search Google Reverse Image

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_reverse_image','image_url':'https://i.imgur.com/5bGzZi7.jpg','max_results':'1',})

Search Google Events

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_events','q':'coffee',})

Search Google Local Services

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_local_services','q':'electrician','data_cid':'6745062158417646970',})

Search Google Maps

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_maps','q':'pizza','ll':'@40.7455096,-74.0083012,15.1z','type':'search',})

Search Google Jobs

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_jobs','q':'coffee',})

Search Google Play

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_play','q':'kite','store':'apps','max_results':'2',})

Search Google Images

importosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_images','tbm':'isch','q':'coffee',})

License

MIT License.

Contributing

Bug reports and pull requests are welcome on GitHub. Once dependencies are installed, you can run the tests withpytest.


[8]ページ先頭

©2009-2025 Movatter.jp