So basically i want to make a system to answer anything from the internet .Hence i want to get the results from the result box in google when a question is asked.How do I do that?
CodePudding user response:
Looks like you're new here. Doing a google search before posting a question here is recommended. Here is the first result, and it looks like what you're looking for.
CodePudding user response:
You could do something like this
import requests
from bs4 import BeautifulSoup
question = "HelloWorld"
URL = f"https://www.google.com/search?q={question}"
r = requests.get(URL)
print(r.status_code)
soup = BeautifulSoup(r.content, 'html5lib')
print(soup.prettify())