获取youtube视频网址表单网页源码 [英] Get youtube video url form webpage source
问题描述
是否有可能从YouTube网页的源代码获取当前播放视频的下载网址?在此先感谢。请帮助我。
其实我有一个下载器,但是它现在不工作。当我尝试了浏览器中下载器提供的URL时,它返回一个错误页面,显示访问网页被拒绝。我为视频获得的网址是 所以我不知道下载器是否提供了正确的URL。请帮助我 我已经编写了一个简单的python代码,可以从html代码中获取youtube href。 https://gist.github.com/Mortezaipo/ 5707738 Is it possible to get the download URL of currently playing video from source of YouTube webpage?Thanks in advance.Please help me. Actually I have a downloader but it is not working now.When I have tried with the URL provided by the downloader in browser it returns an error page says "Access to the webpage was denied".The Url that I got for a video is as
" http://r14---sn-h557snel.c.youtube.com/videoplayback?gcr=in&ip=121.241.181.70&upn=OOcjKEO_S6I&cp=U0hUTFZQT19KU0NONF9OSlNGOmFRT2JSUUs2bDVi&ipbits=8&fexp=900148,920704,912806,928001,922403,922405,929901,913605,929104,913546,913556,908496,920201,913302,919009,911116,901451,902556&ms=au&mt=1357625350&mv=m&id=31a79fcdbfc6c2f6&sparams=cp,gcr,id,ip,ipbits,itag,ratebypass,source,upn,expire&expire=1357651559&itag=18&key=yt1&newshard=yes&source=youtube&ratebypass=yes&sver=3" So I don't know whether the downloader gives the correct URL. Please help me I have written a simple python code that can fetch youtube href from html code.
hope it can help you: https://gist.github.com/Mortezaipo/5707738 这篇关于获取youtube视频网址表单网页源码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
http://r14---sn-h557snel.c.youtube.com/v ideoplayback GCR =在&安培; IP = 121.241.181.70&安培; UPN = OOcjKEO_S6I&安培; CP = U0hUTFZQT19KU0NONF9OSlNGOmFRT2JSUUs2bDVi&安培; ipbits = 8&安培; FEXP = 900148,920704,912806,928001,922403,922405,929901,913605,929104,913546,913556,908496 ,920201,913302,919009,911116,901451,902556和安培; MS = AU&安培; MT = 1357625350&安培; MV =米和ID = 31a79fcdbfc6c2f6&安培; sparams =厘泊,GCR,ID,IP,ipbits,ITAG,ratebypass,来源,UPN,到期&安培; expire = 1357651559& itag = 18& key = yt1& newshard = yes& source = youtube& ratebypass = yes& sver = 3 网址格式前几个月是
http:// oo --- preferred --- sn-h557snes-- -v24---lscache3.c.youtube.com/videoplayback?upn=AmmxhSpq470&sparams=cp,gcr,id,ip,ipbits,itag,ratebypass,source,upn,expire&fexp=917013,906437,916626,922401 ,920704,912806,927201,925706,922403,913546,913556,916805,920201,901451&安培; MS = AU&安培;到期= 1353668177&安培; ITAG = 18&安培; ipbits = 8&安培; GCR =在&安培; sver = 3及ratebypass = YES&安培;山= 1353646087& ip = 121.241.181.70& mv = m& source = youtube& key = yt1& cp = U0hUSFZRVl9MUUNONF9OS1pCOmhtUTVMak5oTVNy& id = c429fa5466ee9447& newshard = yes
希望它可以帮助你:
#!/ usr / bin / env python
import re
pattern ='。*<(iframe | param)。*(src | value)=(?P< link> http://www.youtube.com/(embed | v)/ [A-ZA-Z0-9 / \.\&安培;; = \ + _-?] +);?。* * GT * LT; /(IFRAME | PARAM) >。*'
action = re.compile(pattern)
result = action.findall('< div>< iframe .....>< / iframe> ;< param ......>< / param>< / div>')
打印结果
#!/usr/bin/env python
import re
pattern = '.*<(iframe|param).*(src|value)="(?P<link>http://www.youtube.com/(embed|v)/[a-zA-Z0-9/\.\?&;=\+_-]+);?.*".*>.*</(iframe|param)>.*'
action = re.compile(pattern)
result = action.findall('<div><iframe.....></iframe><param......></param></div>')
print result