Created
September 1, 2019 04:59
-
-
Save lmzach09/720882f0fe3c95f4eede580586117f7e to your computer and use it in GitHub Desktop.
Do a Google search and get the page in the first result with Python 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| from lxml import html | |
| from googlesearch import search | |
| from bs4 import BeautifulSoup | |
| query = 'how old is samuel l jackson' | |
| ## Google Search query results as a Python List of URLs | |
| search_result_list = list(search(query, tld="co.in", num=10, stop=3, pause=1)) | |
| page = requests.get(search_result_list[index]) | |
| tree = html.fromstring(page.content) | |
| soup = BeautifulSoup(page.content, features="lxml") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
so cool!