|
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import threading
- from lxml import etree
- import requests
- from ctypes import windll
- def getmidstring(html, start_str, end):
- start = html.find(start_str)
- if start >= 0:
- start += len(start_str)
- end = html.find(end, start)
- if end >= 0:
- return html[start:end].strip()
- def getleftstring(html, end):
- end = html.find(end)
- if end >= 0:
- return html[0:end].strip()
- def updata(i):
- req = requests.get("https://www.xxx.com/play/xxx-2-%s.html" % i)
- req.encoding = "utf-8"
- m3u8 = getmidstring(req.text, "var now="", """)
- html = etree.HTML(req.text)
- title = html.xpath("//meta[@name="description"]/@content")[0]
- title = getleftstring(title, ",")
- print(title)
- cmd = ""%s" --workDir "%s" --saveName "%s" --enableDelAfterDone" % (
- m3u8,
- r"F:\xxx",
- title)
- print(cmd)
- dll = windll.LoadLibrary("Shell32.dll")
- print(dll.ShellExecuteW(None,
- "open",
- r"D:\xxx.exe",
- cmd, None, 1))
- def cycle():
- for i in range(40):
- updata(i)
- if __name__ == '__main__':
- hThread = threading.Thread(target=cycle)
- hThread.setDaemon(True)
- hThread.start()
- hThread.join()
复制代码
在线追剧又卡又慢!还不方便,写个Python脚本自动帮我缓存下~
|
评分
-
查看全部评分
|