如何使用YouTube Iframes API管理列表

时间:2015-10-20 15:55:14

标签: javascript html iframe video youtube

我在尝试管理个人博客中的视频列表时遇到了一些问题。 所有视频都在iframe标记内(例如//import YT lib var tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); function onYouTubeIframesAPIReady(){ var frame = document.querySelectorAll('iframe[src*="youtube"]'); var player = [frame.length]; for(var i=0; i < frame.length; i++){ //setting enable js api as true so I can manage the events via JS frame[i].src += "&enablejsapi=true"; //incorporate the each frame to a specific place on the array of players player[i] = new YT.Player(frame[i]); player[i].addEventListener('onStateChange', onPlayerStateChange); } } var onPlayerStateChange = function(event){ console.log(event.data); } )。 此博客中有4个视频,我正在尝试衡量这些视频的播放频率。我正在尝试以下代码。

  def filter_tags(htmlstr):
        re_cdata=re.compile('//<!\[CDATA\[.*//\]\]>',re.DOTALL)
        re_script=re.compile('<\s*script[^>]*>[^<]*<\s*/\s*script\s*>',re.DOTALL)#Script
        re_style=re.compile('<\s*style[^>]*>[^<]*<\s*/\s*style\s*>',re.I)#style
        re_br=re.compile('<br\s*?/?>')
        re_h=re.compile('</?\w+[^>]*>')
        re_function = re.compile('')
        re_comment=re.compile('<!--[^>]*-->')
        s=re_cdata.sub('',htmlstr)
        s=re_script.sub('',s) 
        s=re_style.sub('',s)
        s=re_br.sub('',s)
        s=re_h.sub('',s) 
        s=re_comment.sub('',s)
        s = re.sub('\\t','',s)
        s = re.sub(' ','',s)
        return s

执行代码时,返回时出现以下错误:

  

googleads.g.doubleclick.net/pagead/viewthroughconversion/962985656/?aid=AAA...N5v JSNXPEwA&amp; foc_id = sooa4yRKGN_zEE8iknghZA&amp; label = followon_view&amp; ptype = view:1 GET https://googleads.g.doubleclick.net/pagead/viewthroughconversion/962985656/ ... 3DN5 vJSNXPEwA&amp; foc_id = sooa4yRKGN_zEE8iknghZA&amp; label = followon_view&amp; ptype = view net :: ERR_BLOCKED_BY_CLIENT

0 个答案:

没有答案