Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Find The Link for JSON Data of a Certain Website

Tags:

json

android

I just finished a tutorial on how to develop an android application that retrieves updated posts from a Blog using JSON data.

The link to the JSON data used to retrieve the posts, was the blog name ending with "/api/get_recent_summary"

How can I find the link of the JSON data for different websites?

For example the website for The Time Magazine http://time.com

like image 314
AMS91 Avatar asked Dec 05 '14 23:12

AMS91


2 Answers

The quickest and easiest way is to use google developer tools in Google Chrome.

1st go to google developer tools. F12 or Ctrl+Shift+I or top right Ellipsis->More Tools->Developer Tools

2nd Click on the "Network" tab.

3rd click on the "XHR" sub-tab. XHR(XMLHttpRequest)

if a site uses json it will be listed under the XHR sub-tab. You can search through the different return objects, select one and use the "preview" sub-sub-tab to view it.

View JSON View JSON

View JSON URL View JSON URL

Although the above way is the easiest it is not the most stable way of getting the info you need. Many sites make changes to the return data without any notice. This will probably break your app...

I think what you are looking for is an API(Application programming interface). Most web APIs return json or xml. You should start by searching for the api documentation for the specific site that you want to get json data from. Example documentation for sites that have public api feeds are github api or youtub api. Many of these will require authentication in order to get the desired json response but the documentation should show you how to do it.

Using a legitimate web api is the most stable way to go. Meaning your app has less chance of randomly breaking all of the time due to feed changes, url changes... I hope this helps!

like image 67
Tim Avatar answered Oct 31 '22 13:10

Tim


I know this is an older question, but I felt compelled to chime in. If you goal is to simply determine if a site uses JSON for data exchange, then the solution proposed by Tim is a very good solution. However, if you are looking to scrape data from an arbitrary site, there is no guarantee that the site uses JSON as data exchange, as stated by @KenanZahirovic. There are numerous sites that do not do this. Instead they embed the data into the HTML, or use XML, or some other method for getting the content to the client. There is no standard way of doing it, which is why data scraping is so difficult. It requires figuring out how data is transferred and building a client for that.

For scenarios where you need to gather data from multiple sources, you may end up with multiple clients due to the nuances between the sources. This site explains some best practices for data scraping. However, this would likely require a server-side application. Having a server-side application that gathers data and stores it in a database would make the most sense for this scenario. This way you can have a consistent API that the client hits to access the data.

An algorithm has been proposed that can scrape many sites fairly confidently. If you only want to have a client, this may or may not be the best way to go. It all depends on how much processing you want the client to do. If at all possible, try and off load processing to a server.

This answer might be way more than is required, but ,again, I felt compelled to chime in. I am sure the previous answer was sufficient. I do recommend though that you mark an answer as the accepted answer.

Best of luck!

like image 33
czifro Avatar answered Oct 31 '22 11:10

czifro