# 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)
```
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 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/d4/69/b285059d1e3ab119eb9fd072aa3fd9da8da8867296e3cee4349bd74c2d63/googlesearch_python-1.2.5.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```\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\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.2.5",
"project_urls": {
"Homepage": "https://github.com/Nv7-GitHub/googlesearch"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2e5c387b879de452c6c4b5400a52f1c0216aca3aa5740acfd93346f543a20133",
"md5": "a64b26172aa3ad8ffcabcdc3fed69e13",
"sha256": "28ef8ad737951b96ebe8963fbeb9bd2b45cae5c2533df1cc7cb8e72129a785f9"
},
"downloads": -1,
"filename": "googlesearch_python-1.2.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a64b26172aa3ad8ffcabcdc3fed69e13",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 4845,
"upload_time": "2024-08-03T23:18:26",
"upload_time_iso_8601": "2024-08-03T23:18:26.619601Z",
"url": "https://files.pythonhosted.org/packages/2e/5c/387b879de452c6c4b5400a52f1c0216aca3aa5740acfd93346f543a20133/googlesearch_python-1.2.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d469b285059d1e3ab119eb9fd072aa3fd9da8da8867296e3cee4349bd74c2d63",
"md5": "772c461b0211046eb4d524a9274bfe1f",
"sha256": "3c23488374f477fb36e8e2975abc5e4e18794d898d8a2c9c9bf21a1440213e87"
},
"downloads": -1,
"filename": "googlesearch_python-1.2.5.tar.gz",
"has_sig": false,
"md5_digest": "772c461b0211046eb4d524a9274bfe1f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 4510,
"upload_time": "2024-08-03T23:18:28",
"upload_time_iso_8601": "2024-08-03T23:18:28.062864Z",
"url": "https://files.pythonhosted.org/packages/d4/69/b285059d1e3ab119eb9fd072aa3fd9da8da8867296e3cee4349bd74c2d63/googlesearch_python-1.2.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-03 23:18:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Nv7-GitHub",
"github_project": "googlesearch",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "googlesearch-python"
}