A terminal application where you can request weather for an area of choice. This project scrapes data from a weather source wunderground.com which means there are limitations to running the application that will be discussed below. The overall goal was to try out the colly framework for web scraping and using golang for a meteorology based project.
-
Make sure you have the Go programming language installed from Go. Note that this application has only been tested on linux and not windows. It's possible that it could have issues on windows or possibly MacOS, but you're welcome try.
-
Install git from your package manager on linux and use
git clone
this link TerminalWeather, or proceed to this link here and download the zip TerminalWeather and extract it to a directory of your choice. -
After unzipping or cloning the repo, change directories in your respective terminal to the project directory.
-
Once in the
TerminalWeather
directory, run theterminalweather
executable by typing./terminalweather
in your respective terminal. -
After running the
./terminalweather
in your terminal, you'll get the following screen . -
Once here, you can do either of the following...
- Enter a country abbrevation followed by a comma, then enter the name of the city of said country and hit enter.
- Or if you have a US city, then you enter the country abbrevation (in this case
us
) followed by a comma, then the US state abbrevation (for exampleoh
for Ohio), followed by another comma and your city (exampleColumbus
)
Please keep in mind that proper format in either case is as follows [country abbrevation],[city]
or [country abbrevation],[US state abbrevation],[US city]
as in the above example screenshots.
NOTE: It is possible that you get incorrect data or no data at all because the city of interest doesn't actually exist on their site. This mean that the weather station isn't online or the respective city doesn't have an active weather station (this site gets data from weather stations). This means you may need to research your city of interest by looking for an active PWS or Personal Weather Station on their site. Unfortunately, this is an issue that cannot be resolved currently. It is also possible that timeouts occur.
- You get weather reported to the screen in both fahrenheit and celsius and the program ends.
DISCLAIMER: This program scrapes weather data from the site mentioned in the introduction. This means too many requests could result in your ip blacklisted. The developer of this program is not responsible if you abuse the program. You claim all responsibiilty if your ip gets banned from using the site.
- Properly format the URL to be used in the GET request for the weather data
- Target the correct parts of the web page to scrape the data
- Display the returned results to the user in the terminal
- Handle one special case for US where the url has to be formatted to handle US States and their cities
- Convert the temperature result from Fahrenheit to Celsius and display
One finding during this project so far was the issue of not every city being recognized. After searching on the site myself for the reason, it seems the data comes from weather stations that not every city has or has register to the site. This means you need an alternative way of getting weather for your city. This means you may need to research the city for the closest PWS.
This project was fun and it was a good introduction to web scraping with the go programming language. Helped understand a bit more about how the go language works and how to use it for web scraping.