- 在线时间
- 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/python
- , T2 h6 p! u* n) h0 G# -*- coding: utf-8 -*-
- + W+ f. {6 ~; }3 G: R+ j
- I& c3 n' k5 H. r: Pimport threading
- $ \& \4 {; Q) F- a7 G9 Hfrom lxml import etree
- ( N7 i( }( A* x& y' Gimport requests
- / N\" t- c3 R; w1 ?\" q) o9 Hfrom ctypes import windll
- \" ]1 Z( C; D9 Q6 u! Y\" [7 v
- * t! f+ x\" k/ N& E* l
- 5 R, B: z9 X4 B+ g4 ]3 |def getmidstring(html, start_str, end):; n2 ]0 \! |2 I+ v% u3 F3 S& I
- start = html.find(start_str)# u' `2 L2 P7 u, V2 X5 }$ T: D- s
- if start >= 0:
- 3 b, P0 c% ?4 s) Q: c; N1 K start += len(start_str)
- ( l0 }8 E- k; W; X end = html.find(end, start)
- % [5 B8 t! M7 _ if end >= 0:
- % L# B5 r8 d- t2 D return html[start:end].strip()5 j0 ]& S7 K% V, m
- # e- O) s/ `, k5 ?3 k\" F# M8 l3 g9 A\" ]8 Z$ Q
- def getleftstring(html, end): t( b* }; l4 W7 l% o. F
- end = html.find(end)
- 7 S- |' y8 M& u+ @/ ]: A if end >= 0:3 n7 ]0 M$ |+ z3 y- s- ~+ |
- return html[0:end].strip()5 ?7 w* g* K5 f; G) M8 w
- 4 L) y `\" Q& K; S$ m, [
- / C, E9 q+ [0 m0 l4 Q- W# j' tdef updata(i):9 ^8 j2 X8 h5 R# `+ P
- req = requests.get("https://www.xxx.com/play/xxx-2-%s.html" % i)
- \" w' j5 {2 f! f& A req.encoding = "utf-8"
- # W. T$ @% `2 Y6 P9 w1 g4 ] m3u8 = getmidstring(req.text, "var now=\"", "\""): M3 _7 U; ^8 _8 k
- * w) _% U2 L8 [: x$ `6 z0 a html = etree.HTML(req.text)6 E% u2 F5 J# i* e- X$ k
- title = html.xpath("//meta[@name=\"description\"]/@content")[0]9 v6 D- M\" v; D4 S
- title = getleftstring(title, ",")- q6 K& F: I; f6 N, n\" i9 X
- print(title)
- \" s) v8 v' b2 P9 B: j/ r, U( ^
- : @# J5 z# x% l$ {5 e cmd = "\"%s\" --workDir \"%s\" --saveName \"%s\" --enableDelAfterDone" % (
- # z\" P# N; a) V; P m3u8,! W+ X6 t2 i: H% E: p; s) O! o
- r"F:\xxx",' @/ @1 Y1 G- N0 C# l! ^, ~; h, G c
- title)- p6 b' g6 J5 T4 N\" M+ k; k9 x1 S
- print(cmd)8 t, ?2 [! K: ?: T: c\" T) R
- $ R/ _$ f$ K- |: b dll = windll.LoadLibrary("Shell32.dll") K& D+ \' R$ U9 h; S2 ]5 ?
- print(dll.ShellExecuteW(None,, Q\" _( w: W) l! T
- "open",% Y, |/ q& _% Q
- r"D:\xxx.exe",
- # ? u2 x( o/ H' V/ g* f4 `; D cmd, None, 1))
- + H) {( i3 t# w- n3 [. n% c7 J; @* y7 `+ c
- * ~& X8 G9 j: {# T0 o4 kdef cycle():
- 0 ]. \' A' f( u3 y6 X3 d for i in range(40):
- ( K4 G, ~7 l$ G3 r updata(i)
- 7 G( O2 H- E) N6 \: d
- 3 u: v5 K8 o0 d1 M- G; K. W7 w3 R
- if __name__ == '__main__':
- . q; E. B\" C; \; w\" T* t! f/ m hThread = threading.Thread(target=cycle), J9 L6 `9 O2 h8 e! {
- hThread.setDaemon(True)$ k. d# ]+ }+ [- j$ M: G
- hThread.start()
- ) F, I- \( P\" `3 z hThread.join()9 k3 j. ~\" z+ Y1 A; f
8 |1 [% ~+ r- c) w9 o0 O% C% q, t+ p
6 {7 m4 |+ A! g: R: R* M在线追剧又卡又慢!还不方便,写个Python脚本自动帮我缓存下~
7 n- l) D- z5 R1 K2 F/ s: Z4 n0 j8 K7 S1 C2 m* }! v3 \ @7 k0 \
9 |8 G5 j/ V, `) bPython交流群:1047602540 % ?8 I. W/ x% Z- t( T$ j
% \& I3 u; S# g- u* t7 K
9 O8 ~' ^. w) i& ] |
zan
|