- 在线时间
- 7 小时
- 最后登录
- 2021-1-20
- 注册时间
- 2021-1-9
- 听众数
- 3
- 收听数
- 0
- 能力
- 0 分
- 体力
- 23 点
- 威望
- 0 点
- 阅读权限
- 20
- 积分
- 10
- 相册
- 0
- 日志
- 0
- 记录
- 0
- 帖子
- 7
- 主题
- 7
- 精华
- 0
- 分享
- 0
- 好友
- 0
升级   5.26% 该用户从未签到
- 自我介绍
- 我本名为我,那就是我
 |
 - #!/usr/bin/python9 _) a( O) I8 v% S+ h: c* Y
- # -*- coding: utf-8 -*-! N\" j* ^) W5 O\" P\" H- J
- : u: n& \* N8 ~import threading/ a9 i8 Q. n# d( v: ~; n
- from lxml import etree
- 4 D* R; X* x! i7 j) p: zimport requests
- 5 P8 [; [; \* Vfrom ctypes import windll
- ! Z' Q4 v+ K4 d% a3 X& U* F4 X& B1 P u' S
- % [. A6 S: R H+ }, L6 e6 b* X
- def getmidstring(html, start_str, end):
- / b( \5 o8 S\" e/ \! b start = html.find(start_str)2 U; }* ?% v# b$ Z7 J
- if start >= 0:- T+ C' G1 c: t$ M
- start += len(start_str)
- / r$ Z6 E5 K R end = html.find(end, start)
- 4 Z9 U( c\" r- v1 K9 B. w if end >= 0:4 b$ c O# m! l: u2 G/ c. z, {
- return html[start:end].strip()
- ' H7 J l# V4 \$ v9 _
- / {/ h. Z. c- S# \: n% q8 j, z5 p
- 5 u6 ]8 ^7 v N' _: Mdef getleftstring(html, end):+ N; d3 R. _ A# ]% `
- end = html.find(end)- r\" |\" S( h( e0 O$ ?
- if end >= 0:; X/ b x$ Y: \7 A: c/ i5 H
- return html[0:end].strip()
- 1 i$ ?, N2 v* N5 l& {2 P
- ) r5 d7 `4 f( W4 N; G, U! z1 Z+ O0 i$ S( L1 ?; Q
- def updata(i):9 P7 w7 V: E$ C! n; o7 M
- req = requests.get("https://www.xxx.com/play/xxx-2-%s.html" % i)2 J; Y\" W: S/ |+ j# e
- req.encoding = "utf-8"
- \" J3 i; {8 S. V8 b m3u8 = getmidstring(req.text, "var now=\"", "\"")0 M( U\" o6 r' ~( |) B8 p- O
- - H% N* a7 G3 D6 K html = etree.HTML(req.text)) M\" b d5 ?5 ]6 i7 z
- title = html.xpath("//meta[@name=\"description\"]/@content")[0]3 K% H- ]( s/ i3 N4 l+ r. w0 B3 y
- title = getleftstring(title, ",")5 v/ D0 n2 g4 T% |+ a\" j/ k
- print(title)! b' P- F; X9 M9 C8 B2 R
- ; D) K6 f H1 j9 B
- cmd = "\"%s\" --workDir \"%s\" --saveName \"%s\" --enableDelAfterDone" % (\" @0 i' I/ p& l4 i5 w2 B
- m3u8,
- ; H3 ~% h( R u) m# V r"F:\xxx",' Z4 ?7 K, F9 @9 r P7 l
- title)* l9 P- x w4 X; n
- print(cmd)
- ( G, ]6 L8 X1 ]9 V8 t( Z4 e4 c
- 6 c' W$ J1 ~1 T' O n8 ]: c dll = windll.LoadLibrary("Shell32.dll")
- / W) G1 o+ _) w9 P print(dll.ShellExecuteW(None,9 o% d( N# R% e$ \/ V
- "open",3 f5 O+ ]. Y0 _( e; H. S
- r"D:\xxx.exe", H: \2 ~) |; B2 F% r3 Q
- cmd, None, 1))
- ( ^! L* ~! e, l! W* w; Q5 H$ A1 S
- ) y) ?0 } O9 H+ Y2 D\" k\" y+ P0 g5 m& Z1 k' E% t
- def cycle():
- 7 l4 F. u$ W, |8 W4 D for i in range(40):$ K* u0 C! D/ ]3 J
- updata(i)
- 5 H4 @6 M$ N2 S# p9 K' I& e
- ) l4 |$ R1 G; f: N$ D
- , a) N# V; w& P W2 Z! Eif __name__ == '__main__':
- . o# u3 ^. X+ a- N: Z$ @ hThread = threading.Thread(target=cycle)
- 8 p; D1 Y% @7 j0 T L hThread.setDaemon(True)
- 6 A7 W9 n# w7 [! K; B* {# Y S. I hThread.start()! o# R D/ u1 } a; ^$ R* e7 f/ ^6 B
- hThread.join()
- ' l% c8 s5 k3 ~( L7 o
3 L% R6 m6 e3 ^
1 K6 }$ M2 K# n' j1 i2 |/ i* d' X在线追剧又卡又慢!还不方便,写个Python脚本自动帮我缓存下~
5 K# j4 a4 }: D% X; q) z* X0 I" j1 _5 t. }0 X, |* e5 m5 i4 H5 Q
& y* A$ J n7 K; G- p$ n* @Python交流群:1047602540
) W" N, S4 s t. [: i! W: L2 h$ v3 H2 E$ d5 @( k
1 X1 d8 A Y, e
|
zan
|