Reputation: 51
I'm trying to request the weather from Google for an specific place at an specific time. When I get the response the text is in Spanish instead of English. Ie. instead of "Mostly cloudly" I get "parcialmente nublado". I'm using the requests library and BeautifulSoup.
from bs4 import BeautifulSoup
import requests
url = "https://www.google.com/search?q=weather+Nissan+Stadium+Nashville+TN+Thursday+December+29+2022+8:15+PM"
page = requests.get(url)
soup = BeautifulSoup(page.content,"html.parser")
clima = soup.find("div",class_="tAd8D")
print(clima.text)
Output
jueves Mayormente nublado Máxima: 16°C Mínima: 8°C
Desired output:
Thursday Mostly cloudy Maximun : x (fahrenheit) Minimum x(fahrenheit)
Upvotes: 1
Views: 58
Reputation: 13612
The most likely explanation is that Google associates your IP address with a primarily Spanish-speaking region and defaults to giving you results in Spanish.
Try specifying English in your search string by adding hl=en
:
https://www.google.com/search?hl=en&q=my+search+string
Upvotes: 1