I want to get live weather data with web scraping. I was thinking about using BeautifulSoup for this.
<span class="Column--precip--3JCDO">
<span class="Accessibility--visuallyHidden--H7O4p">Chance of Rain</span>
3%
</span>
I want to get the 3% out of this container. I already managed to get data from the website using this code snippet for another section.
temp_value = soup.find("span", {"class":"CurrentConditions--tempValue--MHmYY"}).get_text(strip=True)
I tried the same for the rain_forecast
rain_forecast = soup.find("span", {"class": "Column--precip--3JCDO"}).get_text(strip=True)
But the output my console is delivering is -- for print(rain_forecast).
The only difference I can see is that between the "text" that should be gotten from the span there is another span.
Another way I came across on Stack Overflow is to use Selenium, because the data has not yet been loaded into the variable and therefore the output is --.
But I don't know if this is overkill for my application, or if there is an simpler solution for this problem.
If you want to get table of today forecast you can use this example:
Prints: