Format: application/octet-stream
⬇ Download File (3.3 KB)
   1  Metadata-Version: 2.1
   2  Name: googlesearch-python
   3  Version: 1.3.0
   4  Summary: A Python library for scraping the Google search engine.
   5  Home-page: https://github.com/Nv7-GitHub/googlesearch
   6  Author: Nishant Vikramaditya
   7  Author-email: junk4Nv7@gmail.com
   8  Classifier: Programming Language :: Python :: 3
   9  Classifier: License :: OSI Approved :: MIT License
  10  Classifier: Operating System :: OS Independent
  11  Requires-Python: >=3.6
  12  Description-Content-Type: text/markdown
  13  License-File: LICENSE
  14  Requires-Dist: beautifulsoup4 >=4.9
  15  Requires-Dist: requests >=2.20
  16  
  17  # googlesearch
  18  googlesearch is a Python library for searching Google, easily. googlesearch uses requests and BeautifulSoup4 to scrape Google. 
  19  
  20  ## Installation
  21  To install, run the following command:
  22  ```bash
  23  python3 -m pip install googlesearch-python
  24  ```
  25  
  26  ## Usage
  27  To get results for a search term, simply use the search function in googlesearch. For example, to get results for "Google" in Google, just run the following program:
  28  ```python
  29  from googlesearch import search
  30  search("Google")
  31  ```
  32  
  33  ## Additional options
  34  googlesearch supports a few additional options. By default, googlesearch returns 10 results. This can be changed. To get a 100 results on Google for example, run the following program.
  35  ```python
  36  from googlesearch import search
  37  search("Google", num_results=100)
  38  ```
  39  If you want to have unique links in your search result, you can use the `unique` option as in the following program.
  40  ```python
  41  from googlesearch import search
  42  search("Google", num_results=100, unique=True)
  43  ```
  44  In addition, you can change the language google searches in. For example, to get results in French run the following program:
  45  ```python
  46  from googlesearch import search
  47  search("Google", lang="fr")
  48  ```
  49  You can also specify the region ([Country Codes](https://developers.google.com/custom-search/docs/json_api_reference#countryCodes)) for your search results. For example, to get results specifically from the US run the following program:
  50  ```python
  51  from googlesearch import search
  52  search("Google", region="us")
  53  ```
  54  If you want to turn off the safe search function (this function is on by default), you can do this:
  55  ```python
  56  from googlesearch import search
  57  search("Google", safe=None)
  58  ```
  59  To extract more information, such as the description or the result URL, use an advanced search:
  60  ```python
  61  from googlesearch import search
  62  search("Google", advanced=True)
  63  # Returns a list of SearchResult
  64  # Properties:
  65  # - title
  66  # - url
  67  # - description
  68  ```
  69  If requesting more than 100 results, googlesearch will send multiple requests to go through the pages. To increase the time between these requests, use `sleep_interval`:
  70  ```python
  71  from googlesearch import search
  72  search("Google", sleep_interval=5, num_results=200)
  73  ```
  74  
  75  ```
  76  If requesting more than 10 results, but want to manage the batching yourself? 
  77  Use `start_num` to specify the start number of the results you want to get:
  78  ```python
  79  from googlesearch import search
  80  search("Google", sleep_interval=5, num_results=200, start_result=10)
  81  ```
  82  
  83  If you are using a HTTP Rotating Proxy which requires you to install their CA Certificate, you can simply add `ssl_verify=False` in the `search()` method to avoid SSL Verification.
  84  ```python
  85  from googlesearch import search
  86  
  87  proxy = 'http://API:@proxy.host.com:8080/'
  88  
  89  j = search("proxy test", num_results=100, lang="en", proxy=proxy, ssl_verify=False)
  90  for i in j:
  91      print(i)
  92  ```
  93