# googlesearch
googlesearch is a Python library for searching Google, easily. googlesearch uses requests and BeautifulSoup4 to scrape Google.
## Installation
To install, run the following command:
```bash
python3 -m pip install googlesearch-python
```
## Usage
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:
```python
from googlesearch import search
search("Google")
```
## Additional options
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.
```python
from googlesearch import search
search("Google", num_results=100)
```
If you want to have unique links in your search result, you can use the `unique` option as in the following program.
```python
from googlesearch import search
search("Google", num_results=100, unique=True)
```
In addition, you can change the language google searches in. For example, to get results in French run the following program:
```python
from googlesearch import search
search("Google", lang="fr")
```
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:
```python
from googlesearch import search
search("Google", region="us")
```
If you want to turn off the safe search function (this function is on by default), you can do this:
```python
from googlesearch import search
search("Google", safe=None)
```
To extract more information, such as the description or the result URL, use an advanced search:
```python
from googlesearch import search
search("Google", advanced=True)
# Returns a list of SearchResult
# Properties:
# - title
# - url
# - description
```
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`:
```python
from googlesearch import search
search("Google", sleep_interval=5, num_results=200)
```
```
If requesting more than 10 results, but want to manage the batching yourself?
Use `start_num` to specify the start number of the results you want to get:
```python
from googlesearch import search
search("Google", sleep_interval=5, num_results=200, start_result=10)
```
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.
```python
from googlesearch import search
proxy = 'http://API:@proxy.host.com:8080/'
j = search("proxy test", num_results=100, lang="en", proxy=proxy, ssl_verify=False)
for i in j:
print(i)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Nv7-GitHub/googlesearch",
"name": "googlesearch-python",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Nishant Vikramaditya",
"author_email": "junk4Nv7@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/00/c8/3f76213025b77de23f11d3f87349ff9825cf3b0054f62156858af1bd94f3/googlesearch_python-1.3.0.tar.gz",
"platform": null,
"description": "# googlesearch\ngooglesearch is a Python library for searching Google, easily. googlesearch uses requests and BeautifulSoup4 to scrape Google. \n\n## Installation\nTo install, run the following command:\n```bash\npython3 -m pip install googlesearch-python\n```\n\n## Usage\nTo 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:\n```python\nfrom googlesearch import search\nsearch(\"Google\")\n```\n\n## Additional options\ngooglesearch 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.\n```python\nfrom googlesearch import search\nsearch(\"Google\", num_results=100)\n```\nIf you want to have unique links in your search result, you can use the `unique` option as in the following program.\n```python\nfrom googlesearch import search\nsearch(\"Google\", num_results=100, unique=True)\n```\nIn addition, you can change the language google searches in. For example, to get results in French run the following program:\n```python\nfrom googlesearch import search\nsearch(\"Google\", lang=\"fr\")\n```\nYou 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:\n```python\nfrom googlesearch import search\nsearch(\"Google\", region=\"us\")\n```\nIf you want to turn off the safe search function (this function is on by default), you can do this:\n```python\nfrom googlesearch import search\nsearch(\"Google\", safe=None)\n```\nTo extract more information, such as the description or the result URL, use an advanced search:\n```python\nfrom googlesearch import search\nsearch(\"Google\", advanced=True)\n# Returns a list of SearchResult\n# Properties:\n# - title\n# - url\n# - description\n```\nIf 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`:\n```python\nfrom googlesearch import search\nsearch(\"Google\", sleep_interval=5, num_results=200)\n```\n\n```\nIf requesting more than 10 results, but want to manage the batching yourself? \nUse `start_num` to specify the start number of the results you want to get:\n```python\nfrom googlesearch import search\nsearch(\"Google\", sleep_interval=5, num_results=200, start_result=10)\n```\n\nIf 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.\n```python\nfrom googlesearch import search\n\nproxy = 'http://API:@proxy.host.com:8080/'\n\nj = search(\"proxy test\", num_results=100, lang=\"en\", proxy=proxy, ssl_verify=False)\nfor i in j:\n print(i)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python library for scraping the Google search engine.",
"version": "1.3.0",
"project_urls": {
"Homepage": "https://github.com/Nv7-GitHub/googlesearch"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "60a6c1fe6a46a7ac2d3b08acfe88ce3d2b12cd8351c697ee4b300bfa350b7c9a",
"md5": "0442f95723d267a4e8111a85175add7c",
"sha256": "808c4dd390dc4c6a1cfba2f5151f5ef16dceb0a200d9770b388dcd39162b4e19"
},
"downloads": -1,
"filename": "googlesearch_python-1.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0442f95723d267a4e8111a85175add7c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 5563,
"upload_time": "2025-01-21T02:31:22",
"upload_time_iso_8601": "2025-01-21T02:31:22.102216Z",
"url": "https://files.pythonhosted.org/packages/60/a6/c1fe6a46a7ac2d3b08acfe88ce3d2b12cd8351c697ee4b300bfa350b7c9a/googlesearch_python-1.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "00c83f76213025b77de23f11d3f87349ff9825cf3b0054f62156858af1bd94f3",
"md5": "aa7a1d9a7c7380865507b3fe38f3b31d",
"sha256": "c5729b1247c2a8f5c4b48ed73c4f8e9fd558ac4e09de67865479f0a33f2d97dc"
},
"downloads": -1,
"filename": "googlesearch_python-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "aa7a1d9a7c7380865507b3fe38f3b31d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 5191,
"upload_time": "2025-01-21T02:31:24",
"upload_time_iso_8601": "2025-01-21T02:31:24.285084Z",
"url": "https://files.pythonhosted.org/packages/00/c8/3f76213025b77de23f11d3f87349ff9825cf3b0054f62156858af1bd94f3/googlesearch_python-1.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-21 02:31:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Nv7-GitHub",
"github_project": "googlesearch",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "beautifulsoup4",
"specs": [
[
">=",
"4.9"
]
]
},
{
"name": "requests",
"specs": [
[
">=",
"2.20"
]
]
}
],
"lcname": "googlesearch-python"
}