Site icon StackBlogger

How to get data from website that does not provide API

There are lot of junk data now-a-days around the world and in this time if you find a good website from where you want to get data programmatically in your code but you realize they do not provide an api then it will make you mad. But I have a solution by which you can get data from website that does not provide an API and it will be a JSON response. Yes you heard it right! It will be a JSON response. Let’s start the journey.


I will take an example of a news website The Hindu. I will show you how you can search for a query in their site and get the JSON response.

Search Engine Setup

I will help you setup a Search Engine at Google which will search for the data at their website and get back to you with JSON response.

Programmable Search Engine Dashboard
Custom Search Engine created

Customize Your Search Engine

Now that you have created your own search engine, it’s time to customize it and get the API out of it.

Click on the “Customize” button in the dashboard where you just added the website.

Copy the “cx” value from the “Public URL” at Search Engine dashboard.

Get the cx value to be used in the Search Engine API

Get the API Key

The next step is to get the Programmable Search Engine API Key.

Get a Key for your Custom Search Engine
Your Custom Search Engine Key

Call the API

The final step is to call the Search API. Use the below GET API to search for a query on the website.

Replace <your key> with your Key Value. <your cx value> with your cx value. and put a query to search for.

Custom Search Engine query result

Conclusion

We learnt about how to make our own custom search engine and search for contents on a website even if that website is not providing any API. Google Programmable Search Engine is giant tool to search for contents throughout the Web or a Particular website.

If you are looking to search for a post or keyword in different Social Media Platforms using your Node.Js code then you must follow this SHAHED NASSER‘s blog to search through different Social Media Platforms using Node.Js.