-3

I would like to convert HTML site to Javascript Object, For example if user given the url in text box "http://Host/page" then need to scrape the website and convert it to javascript object like below ,

{
    "rootId": 1,
    "children": [
        {
            "nodeType": 10,
            "id": 2,
            "name": "html",
            "publicId": "",
            "systemId": ""
        },
        {
            "nodeType": 1,
            "id": 3,
            "tagName": "HTML",
            "attributes": {
                "lang": "en"
            },
            "childNodes": [
                {
                    "nodeType": 1,
                    "id": 4,
                    "tagName": "HEAD",
                    "attributes": {},
                    "childNodes": [
                        {
                            "nodeType": 3,
                            "id": 5,
                            "textContent": "\n"
                        },
                        {
                            "nodeType": 1,
                            "id": 6,
                            "tagName": "TITLE",
                            "attributes": {},
                            "childNodes": [
                                {
                                    "nodeType": 3,
                                    "id": 7,
                                    "textContent": "About"
                                }
                            ]
                        },......

Any Help Appreciated

Jan
  • 2,178
  • 3
  • 14
  • 26
Smarty
  • 1
  • 4
  • Possible duplicate: https://stackoverflow.com/questions/12980648/map-html-to-json – Tom Dezentje Sep 24 '19 at 07:18
  • Why, there are no specs for that format - for example nodeType numbers ? You have similar properties in DOM directly, so do not understand purpose this translation. Or in case you have text, will not https://developer.mozilla.org/en-US/docs/Web/API/DOMParser help ? – Jan Sep 24 '19 at 07:19
  • What have you tried? Where did your code fail? Or are you expecting someone else to write everything for you? – agrm Sep 24 '19 at 07:20
  • Possible duplicate of [Map HTML to JSON](https://stackoverflow.com/questions/12980648/map-html-to-json) – RobC Sep 24 '19 at 08:00

1 Answers1

0

Try yahoo query language (YQL) https://developer.yahoo.com/yql/guide/select.html