Get data from script tag with Scrapy Xpath

吃可爱长大的小学妹 提交于 2020-01-07 05:38:14

问题


I've been trying to extract data from script tag using Scrapy(xpath). My main issue is with identifying the correct div and script tags. I'm new to using xpath and would appreciate any help!

<script>
    (function(e, a) {
            var t = {
                "cdn_url": "https://f.vimeocdn.com",
                "view": 1,
                "request": {
                    "files": {
                        "dash": {
                            "separate_av": true,
                            "streams": [{
                                "profile": 164,
                                "quality": "360p",
                                "id": 830872409,
                                "fps": 30
                            }, {
                                "profile": 175,
                                "quality": "1080p",
                                "id": 830872420,
                                "fps": 30
                            }]
                            "default_cdn": "akfire_interconnect_quic"
                        },
                        "progressive": [{
                            "profile": 165,
                            "width": 960,
                            "mime": "video/mp4",
                            "fps": 30,
                            "url": "https://gcs-vimeo.akamaized.net/exp=1512626028~acl=%2A%2F830872419.mp4%2A~hmac=f6990c94f8fe004ec50059b0c1c648441faa41b248a14e881826a4b1233676c3/vimeo-prod-skyfire-std-us/01/1812/9/234061739/830872419.mp4",
                            "cdn": "akamai_interconnect",
                            "quality": "540p",
                            "id": 830872419,
                            "origin": "gcs",
                            "height": 540
                        }, {
                            "profile": 174,
                            "width": 1280,
                            "mime": "video/mp4",
                            "fps": 30,
                            "url": "https://gcs-vimeo.akamaized.net/exp=1512626028~acl=%2A%2F830872411.mp4%2A~hmac=ad12d7e5de00edb54c2360e23429d4a5de6aa0800ff7f4273f2ecc4495171707/vimeo-prod-skyfire-std-us/01/1812/9/234061739/830872411.mp4",
                            "cdn": "akamai_interconnect",
                            "quality": "720p",
                            "id": 830872411,
                            "origin": "gcs",
                            "height": 720
                        }, {
                            "profile": 164,
                            "width": 640,
                            "mime": "video/mp4",
                            "fps": 30,
                            "url": "https://gcs-vimeo.akamaized.net/exp=1512626028~acl=%2A%2F830872409.mp4%2A~hmac=26c477008c9a74d4ceca9895c5307ab19c6ef79e7480e833a503f15ea60bdf2b/vimeo-prod-skyfire-std-us/01/1812/9/234061739/830872409.mp4",
                            "cdn": "akamai_interconnect",
                            "quality": "360p",
                            "id": 830872409,
                            "origin": "gcs",
                            "height": 360
                        }]
                    },
                    .....
</script>

I finally want to populate "url" from "progressive" where "width"= 960 into my items.

来源:https://stackoverflow.com/questions/47721021/get-data-from-script-tag-with-scrapy-xpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!