I am trying to parse the first page of google search results. Specifically, the Title and the small Summary that is provided. Here is what I have so far:
fro
Your url doesn't work for me. But with https://google.com/search?q=
I get results.
import urllib
from bs4 import BeautifulSoup
import requests
import webbrowser
text = 'hello world'
text = urllib.parse.quote_plus(text)
url = 'https://google.com/search?q=' + text
response = requests.get(url)
#with open('output.html', 'wb') as f:
# f.write(response.content)
#webbrowser.open('output.html')
soup = BeautifulSoup(response.text, 'lxml')
for g in soup.find_all(class_='g'):
print(g.text)
print('-----')
Read Beautiful Soup Documentation