Crawling weather information from weather website

+2 Matthijs Koningstein · January 21, 2016
Hi all,

as I´m fairly new to programming, but decided it would be much cheaper and much much more fun to build and program my own aquarium computer, I´ve been learning each and every day, with a whole lot of fun. 

Now I´m at the point where I´d like to get weather information from a website of my choosing, and import them in my gui. 

Like I said, I´m new to programming, so I´d like some pointers on how to get the data as shown in below text

<span class="weather-map__table-cell margin-top-10">
            <span class="weather-map__label">Zonneschijn</span>

The 20% is what I´m looking to import. 

Any help is much appreciated. 



Post a Reply


Oldest  Newest  Rating
0 Matthijs Koningstein · January 22, 2016
The legality issue is something I haven't thought of yet. Thanks for pointing me towards potential issues. 

As for the code: 

(result.contents[0]) was what I was looking for. The rest of the code I'd gotten from one of the tutorials. Next time I'll post what I've gotten sofar, That'll help for sure.

0 john lalani · January 22, 2016
Just make sure you stay in the zone of "permission" when it comes to the legality of it. If it's data that can be browsed through with a popular browser & not used for commercial purposes it's fine.

As in for Mustafa Fakhrualdin's code, typos:

result = soup.findAll('span', {"class": 'weather-map__table-cell margin-top-10'})
print (result.contents[0])

.stripped_strings to get results from contents that contain pictures. The docs will surely help for other problems.
+2 Mustafa Fakhrualdin · January 22, 2016
You first have to import modules 
import requests
from bs4 import BeautifulSoup

then You have to target the website
url = "http:/" 
source_code = requests.get(url)
html_code = source_code.text

Now that we gottin into the website. we are ready to take information

soup = BeautifulSoup(html_code, "html.parser")
result = soupfindAll('span', {"class": 'weather-map__table-cell margin-top-10'})
  • 1



This section is all about snakes! Just kidding.

Bucky Roberts Administrator