I would like to extract some JSON data from the following url:
http://weather.news24.com/sa/johannesburg.
I used the Google developer tools which gave me some JSON and when I tried some online JSON validators, it's failing somehow on dates. Is there anyway I can get around the issue and correctly get the selected city JSON data?
Any help will be appreciated.
If the site does not offer a RESful service, then you may need to ask them if you want to scrape their page. Web page scraping is very tedious and the site's DOM structure could change at any time. There is no guarantee.
Page Scraping
You can scrape the page and convert the table data into a JSON object. I copied the DOM of the webpage as a bassis for this implementation.
If you generate the results below, the following response should be at the bottom.
Example
RESTful Options
There are free REST APIs that return JSON weather data. All you need to do is sign up and receive a key.
OpenWeatherMap
API: http://openweathermap.org/api
Request:
Responsehttp://api.openweathermap.org/data/2.5/weather?q=johannesburg,za&appid=YOUR_KEYWeather Underground
API: https://www.wunderground.com/weather/api/
Request:
Responsehttp://api.wunderground.com/api/YOUR_KEY/conditions/q/ZA/Johannesburg.json