【问题标题】:gettint youtube video's titles获取 youtube 视频标题
【发布时间】:2016-11-27 18:38:26
【问题描述】:

我正在尝试使用 Chrome 和 CORS 扩展程序从 youtube 页面获取视频标题。

$.get('https://www.youtube.com/user/SERLYMAR/videos', function (html) {
var $html = $(html);
console.log($html.find('a.yt-ui-ellipsis-2').text());

它有效,但在列出标题后,我收到以下错误(很多次):

Uncaught ReferenceError: __ytRIL is not defined
    at HTMLImageElement.onload (http://localhost/extract-titles/:1:2)onload @ (index):1
(index):1 Uncaught ReferenceError: __ytRIL is not defined(…)onload @ (index):1

【问题讨论】:

  • 见评论here
  • @FrankerZ,这是否意味着没有解决方案?

标签: javascript google-chrome youtube


【解决方案1】:

尝试将dataType 设置为文本,以防止您的脚本解析远程页面中的脚本标签。

$.ajax({
    dataType: 'text',
    url: 'https://www.youtube.com/user/SERLYMAR/videos',
    success: function (html) {
        var $html = $(html);
        console.log($html.find('a.yt-ui-ellipsis-2').text());
    }
});

【讨论】:

    猜你喜欢
    • 2013-03-23
    • 2015-08-09
    • 1970-01-01
    • 2015-10-23
    • 2010-11-16
    • 2012-03-28
    • 1970-01-01
    • 2017-10-14
    • 2012-05-22
    相关资源
    最近更新 更多