Code Monkey home page Code Monkey logo

google-search-python's Introduction

Use the Google Custom Search API to search the web from Python.

This is by no means a finished library!

Quick start

from google_search import GoogleCustomSearch


SEARCH_ENGINE_ID = os.environ['SEARCH_ENGINE_ID']                           
API_KEY = os.environ['GOOGLE_CLOUD_API_KEY']

api = GoogleCustomSearch(SEARCH_ENGINE_ID, API_KEY)

for result in api.search('pdf', 'http://scraperwiki.com'):
    print(result['title']) 
    print(result['link']) 
    print(result['snippet']) 

See these instructions (although the process wasn't completely the same):

http://stackoverflow.com/a/11206266

1. Make a Google Custom Search Engine

2. Make a Google Cloud Console "Project" to get API key

  • Provides an API key - explained in the developer docs at https://developers.google.com/custom-search/json-api/v1/overview

  • You need to enable access to Custom Search service

  • Allows separating billing for different projects, using the same custom search engine.

  • To view your quota, go to "APIs & auth" => "APIs" => "Custom Search API" => "Quota" at the top.

When you make a Cloud Project, you need to enable the "Custom Search API" feature.

To get an API key, go to "APIs & Auth" => Registered apps => Register New App => Web Application => Server Key

Limitations

If you try and search across more than 10 sites (including "the whole web") you'll get results from a limited subset of the Google Index:

https://support.google.com/customsearch/answer/70392?hl=en

"""If your custom search engine includes more than ten sites, the results may be from a subset of our index and may differ from the results of a 'site:' search on Google.com."""

google-search-python's People

Contributors

stevenmaude avatar

Watchers

James Cloos avatar 张宝才 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.