如何从 Twitter 中的嵌入链接获取视频 URL

逆向工程 javascript 网站
2021-07-08 01:50:16

我正在尝试获取 ( https://twitter.com/i/videos/823649890379120640?embed_source=facebook )的视频 URL

我尝试查看源代码,但它给出了相同的 URL 链接

<meta  property="og:video:url" content="https://twitter.com/i/videos/823649890379120640?embed_source=facebook">

有什么技巧可以获取视频的 URL 或它们的位置吗?

3个回答

您正在查看错误的代码段。Twitter 具有轻微混淆的 javscript。订购,你会收到这样的东西:

{
"duration": 55322,
"scribe_widget_origin": true,
"heartbeatEnabled": false,
"video_url": "https:\/\/video.twimg.com\/ext_tw_video\/823648834102272000\/pu\/pl\/BZiFV49f1BCX2JkK.m3u8",
"disable_embed": "0",
"videoInfo": {
    "title": null,
    "description": null,
    "publisher": {
        "screen_name": "VinePhilly",
        "name": "Global",
        "profile_image_url": "https:\/\/pbs.twimg.com\/profile_images\/822579605177532418\/ZS3emkF8_normal.jpg"
    }
},
"cardUrl": "https:\/\/t.co\/dpfYidciVZ",
"content_type": "application\/x-mpegURL",
"owner_id": "2495729384",
"looping_enabled": true,
"show_cookie_override_en": true,
"visit_cta_url": null,
"scribe_playlist_url": "https:\/\/twitter.com\/VinePhilly\/status\/823649890379120640\/video\/1",
"source_type": "consumer",
"image_src": "https:\/\/pbs.twimg.com\/ext_tw_video_thumb\/823648834102272000\/pu\/img\/XgQjj1Y0_Sclf2SY.jpg",
"heartbeatIntervalInMs": 5000.0,
"use_tfw_live_heartbeat_event_category": true,
"video_loading_timeout": 45000.0,
"status": {
    "created_at": "Mon Jan 23 21:53:31 +0000 2017",
    "id": 823649890379120640,
    "id_str": "823649890379120640",
    "text": "Bro They Had A Picnic In Walmart \ud83d\ude2d https:\/\/t.co\/dpfYidciVZ",
    "truncated": false,
    "entities": {
        "hashtags": [],
        "symbols": [],
        "user_mentions": [],
        "urls": [],
        "media": [{
            "id": 823648834102272000,
            "id_str": "823648834102272000",
            "indices": [35, 58],
            "media_url": "http:\/\/pbs.twimg.com\/ext_tw_video_thumb\/823648834102272000\/pu\/img\/XgQjj1Y0_Sclf2SY.jpg",
            "media_url_https": "https:\/\/pbs.twimg.com\/ext_tw_video_thumb\/823648834102272000\/pu\/img\/XgQjj1Y0_Sclf2SY.jpg",
            "url": "https:\/\/t.co\/dpfYidciVZ",
            "display_url": "pic.twitter.com\/dpfYidciVZ",
            "expanded_url": "https:\/\/twitter.com\/VinePhilly\/status\/823649890379120640\/video\/1",
            "type": "photo",
            "sizes": {
                "small": {
                    "w": 340,
                    "h": 425,
                    "resize": "fit"
                },
                "large": {
                    "w": 480,
                    "h": 600,
                    "resize": "fit"
                },
                "thumb": {
                    "w": 150,
                    "h": 150,
                    "resize": "crop"
                },
                "medium": {
                    "w": 480,
                    "h": 600,
                    "resize": "fit"
                }
            }
        }]
    },
    "source": "\u003ca href=\"http:\/\/twitter.com\/download\/iphone\" rel=\"nofollow\"\u003eTwitter for iPhone\u003c\/a\u003e",
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "in_reply_to_screen_name": null,
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "retweet_count": 0,
    "favorite_count": 0,
    "favorited": false,
    "retweeted": false,
    "possibly_sensitive": false,
    "lang": "en"
},
"show_cookie_override_all": true,
"video_session_enabled": false,
"media_id": "823648834102272000",
"view_counts": null,
"statusTimestamp": {
    "local": "1:53 PM - 23 Jan 2017"
},
"media_type": 1,
"user": {
    "screen_name": "VinePhilly",
    "name": "Global",
    "profile_image_url": "https:\/\/pbs.twimg.com\/profile_images\/822579605177532418\/ZS3emkF8_bigger.jpg"
},
"watch_now_cta_url": null,
"tweet_id": "823649890379120640"
}

您应该可以从这里访问视频网址。还有一个提示:“video_url”指向一个播放列表文件。由于法律义务,我不会这样做。

我希望这有帮助

youtube-dl是一个很好的程序,可以从许多网站下载媒体内容,包括 twitter(和尽管程序名称)。它是开源的,研究它可以帮助理解如何检索正确的 URL 和其他各种东西(媒体质量等)

是的你可以。原帖在这里

说明:

在您的链接中: https://twitter.com/i/videos/823649890379120640?embed_source=facebook

您可以看到包含一些信息的 JSON。

  • "statusTimestamp":{"local":"21:53 - 23 janv. 2017"}
  • "user":{"screen_name":"VinePhilly" ...}
  • "tweet_id":"823649890379120640"

因此,您可以https://twitter.com/VinePhilly使用https://twitter.com/VinePhilly/status/823649890379120640.

模式是: https://twitter.com/用户/状态/ tweet_id