当youtube上有现场直播时,总是在视频播放器的右边聊天。我正在尝试从聊天下载消息到我的PHP页面,以便过滤掉它们,因为它们滚动得非常快,我无法赶上它们。
我注意到当你用实时聊天打开youtube页面时,它每10秒运行一次这个URL
https://www.youtube.com/live_comments?action_get_comments=1&video_id=<video_id><=<timestamp of last recorded message>&format=proto&pd=10000&rc=26&scr=true&comment_version=1如果我做了
$xml= file_get_contents('https://www.youtube.com/live_comments?action_get_comments=1&video_id=<video_id><=<timestamp of last recorded message>&format=proto&pd=10000&rc=26&scr=true&comment_version=1');
echo "<textarea>{$xml}</textarea>";我被跟踪了
<?xml version="1.0" encoding="utf-8"?>
<root>
<latest_time>
<![CDATA[1445398692]]>
</latest_time>
<return_code>
<![CDATA[0]]>
</return_code>
<likes_data>
<![CDATA[{"percent_dislikes":7,"num_likes":"1,383","num_dislikes":"91","percent_likes":93}]]>
</likes_data>
<comments>
<![CDATA[EOcKGFsgkE4=]]>
</comments>
</root>我想这会给我带来新的消息出现,但我目前正在测试的聊天,没有人在其中,我无法证实。
也有每10秒发布请求,但我不是试图张贴,只是下载。
我的问题是,当您最初打开页面时,如何下载显示在聊天中的PHP现有消息?
发布于 2019-05-04 02:32:25
这不是一个足够的答案(没有PHP,没有代码.),但是如果您对一个肮脏而简单的解决方案感兴趣(将Youtube Live视频聊天抓取为JSON),您可以使用浏览器这样做。在Firefox中:
https://stackoverflow.com/questions/33251041
复制相似问题