-2

How do I use .getJSON() to get JSON-encoded data from a website that is searched?

I create a Google Custom Search API for my website, and my goal is to retrieve the JSON file from the result. Let's say when I typed "apple" in my Google Custom Search bar from my website, the result would look like what this picture shows

Googel search result

How do you retrieve the JSON object from this result? Such as the title, URL, and the description? Thank you!

xxColderxx
  • 53
  • 6

1 Answers1

2

The result is not returned as JSON but HTML, you should inspect the HTML form (debugger) and how you can build your own functions that turn a html structure to a JSON structure!

Also there is lot of librairies that doing the conversion HTML to JSON. Here is one of them : https://github.com/Jxck/html2json ...

Mohamed Taboubi
  • 6,663
  • 11
  • 55
  • 87