Created
August 9, 2018 13:47
-
-
Save guillaumeguerin/173e8d3687df38aa4f2cb38e7794c555 to your computer and use it in GitHub Desktop.
Weather Scraper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Example url : https://www.timeanddate.com/weather/?continent=europe | |
| var cityName = ""; | |
| var weather = ""; | |
| var temperature = ""; | |
| var rows = document.getElementsByTagName("tbody")[0].getElementsByTagName("tr"); | |
| for(i=0; i<rows.length; i++) { | |
| cityName = rows[i].children[0].innerText.replace(" *",""); | |
| weather = rows[i].children[2].children[0].getAttribute("alt"); | |
| temperature = rows[i].children[3].innerText.replace(" °C",""); | |
| console.log(cityName + ";" + weather + ";" + temperature); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example :