打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
python脚本抓取优酷在线视频地址代码
1 import re
2 import sys
3 import urllib
4 import urllib2
5 import datetime
6 from win32clipboard import *
7 from win32con import CF_TEXT
8
9 def get_Clipboard():   
10          OpenClipboard()   
11          text = GetClipboardData(CF_TEXT)
12          CloseClipboard()
13          return text
14
15
16
17 class CFlvcd(object):
18     def __init__(self):
19         self.url = ""
20         self.pattern = re.compile(r"<a href *= *\"(http://f\.youku\.com/player/getFlvPath/[^\"]+)")
21         self.headers = {"Accept":"*/*", "Accept-Language":"zh-CN", "":"",
22                         "User-Agent":"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)",
23                         #"Accept-Encoding":"gzip, deflate",
24                         "Connection":"Keep-Alive"}
25 
26     def parse(self, url):
27         self.url = "http://www.flvcd.com/parse.php?kw=" + url + "&format=super"
28         req = urllib2.Request(url=self.url, headers=self.headers)
29         res = urllib2.urlopen(req)
30         data = res.read()
31         re_res = self.pattern.findall(data)
32         if re_res != None:
33             filename = datetime.datetime.now().strftime("%Y%m%d-%H%M%S.lst")
34             fhandle = open(filename, "w")
35             for url in re_res:
36                 # 注意是\r\n还是\n
37                 fhandle.write(url + "\n")
38             fhandle.close()
39             print("Parse URL Done!")
40         else:
41             print("URL Not Found")
42
43 def main():
44     flvcd=CFlvcd()
45     print'你要下载的视频地址是'
46     print get_Clipboard()
47     print'确定获取请按1'
48     a=raw_input()
49     if (a=='1'):
50        flvcd.parse(get_Clipboard())
51    
52    
53    
54
55 if __name__ == "__main__":
56     main()
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Skr-Eric的爬虫课堂(二)——爬虫的解析模块和数据持久化存储
零基础写python爬虫之爬虫编写全记录
爬虫之Scrapy框架
最人性化的Python网络爬虫requests模块,下载百度贴吧和博客标题
scrapy实践之翻页爬取
[经验]Python获取本机IP(外网IP)的方法总结
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服