用Python嗅探视频的真实地址!
这个是借力打力,只是抓去朋友网的内容!!!
不过相当好用哦!
以前发布过PHP版的(查看),这次来个Python版的,不过需要用到requests这个模块,这里传送门
看代码:
#!/usr/bin/env python
#coding: utf8
import requests
def main():
videourl='http://v.youku.com/v_show/id_XNTIzMjI4OTky.html'
datas = {'url': videourl}
rs = requests.post('http://share.pengyou.com/json.php?mod=usershare&act=geturlinfo' ,data=datas)
print rs.content
if __name__ == '__main__':
main()
返回如下信息:
{"code":0,"err":0,"msg":"u83b7u53d6u6210u529f","ATT":"@success@","test_msg":"@success@","result":{"coverurl":"http://g2.ykimg.com/0100641F465137D08592FA03B99CC86C873705-0A63-F31C-412E-E825E7923AAE","desc":"","flash":"http://player.youku.com/player.php/partnerid/XOTcy/sid/XNTIzMjI4OTky/v.swf","title":"u90a3u5e74u51acu5929u8d77u98ceu4e86 08","type":5,"vid":"","uin":0,"hash":"","name":"u672au77e5"}}
是字符串类型的,需要转成字典
result = eval(rs.content)
print result['result']['coverurl'].replace('','')