Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get number of search results from Google
def get_n_results_dumb(q):
r = requests.get('',
params={'q': q,
"tbs": "li:1"})
soup = bs4.BeautifulSoup(r.text)
s = soup.find('div', {'id': 'resultStats'}).text
if not s:
return 0
m ='([0-9,]+)', s)
return int(m.groups()[0].replace(',', ''))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment