Skip to content

Instantly share code, notes, and snippets.

@lmzach09
Created September 1, 2019 04:59
Show Gist options
  • Select an option

  • Save lmzach09/720882f0fe3c95f4eede580586117f7e to your computer and use it in GitHub Desktop.

Select an option

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
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")
@albedim

albedim commented Jan 26, 2023

Copy link
Copy Markdown

so cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment