0

In a website, I have the following javascript enclosed within the <script> tag:

(function(e, t) {
    var a = {
        "cdn_url": "https://f.playerabc.com",
        "playerabc_api_url": "api.playerabc.com",
        "view": 1,
        "request": {
            "files": {
                "dash": {
                   ...
                    }],
                    "cdns": {
                      ...
                        }
                    },
                    "default_cdn": "akfire_interconnect_quic"
                },
                "hls": {
                   ...
                        }
                    }
                },
                "progressive": [{
                    "profile": 165,
                    "width": 960,
                    "mime": "video/mp4",
                    "fps": 24,
                    "url": "https://url1.com/893184125.mp4",
                    "cdn": "mai_connect",
                    "quality": "540p",
                    "id": 893184125,
                    "origin": "gcs",
                    "height": 540
                }, {
                    "profile": 164,
                    "width": 640,
                    "mime": "video/mp4",
                    "fps": 24,
                    "url": "https://url2.com/893184120.mp4",
                    "cdn": "mai_connect",
                    "quality": "360p",
                    "id": 893184120,
                    "origin": "gcs",
                    "height": 360
                }, {
                    "profile": 174,
                    "width": 1280,
                    "mime": "video/mp4",
                    "fps": 24,
                    "url": "https://url3.com/893184095.mp4", 
                    "cdn": "mai_connect",
                    "quality": "720p",
                    "id": 893184095,
                    "origin": "gcs",
                    "height": 720
                }]
            },
           ...
    };

I want to extract the link of the url having 720p video (https://url3.com/893184095.mp4)

How do I do this?

1
  • I have answered but I would like to note that this is a question for StackOverflow
    – wmash
    Commented Feb 26, 2018 at 7:45

1 Answer 1

0

If you are sure that is the object structure, you can access the URL(s) via dot notation:

var url = a.request.files.progressive[1].url;

This will assign 'url' to the url you gave in the example. If you want to extract the others with the 'progressive' object, change the number inside the [] to either 0 or 2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .