- 在线时间
- 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( p4 H, g9 r% E# d( h# ]
- # -*- coding: utf-8 -*-
- 0 S) ]) \: Q) c# R. T; m# B
- 5 {% u; V# ^; l2 B\" Bimport threading; s9 B# b3 U% G% c
- from lxml import etree- j, g8 R2 t' k) c% N& t- _
- import requests4 j4 C8 E: d) n
- from ctypes import windll, }1 t9 _9 v! p9 G1 k
- ) T) @4 U1 \: C- n% ?$ e4 d
- ) E5 o: S1 V ]5 s7 x+ I9 D4 o
- def getmidstring(html, start_str, end):
- 6 i8 i# k. r E+ T\" _3 a: V! M start = html.find(start_str)
- 7 b; d) k @! V, n! O if start >= 0:5 T% j) }* s/ I6 {) t
- start += len(start_str)
- ' j; ~4 o) t0 S5 D) f/ [1 j$ { end = html.find(end, start)( u+ K+ @' E2 m- V# g8 Y9 m
- if end >= 0:4 ?9 P1 P' }! G1 a7 s! b& r2 w; N* b
- return html[start:end].strip()
- 9 w4 {0 j: ?% Q! P
- % } i+ z4 V/ y8 ~* z/ X) x4 l! m! A+ J5 N6 B1 y! o
- def getleftstring(html, end):7 ~# U. z0 j( O) H. x
- end = html.find(end)
- ) d6 m: {+ A0 s f, U; U if end >= 0:
- . q) |! Y\" P( Z4 i5 n R q( @1 V5 x return html[0:end].strip(): x2 S7 F9 v0 v
- 6 R7 Z( P5 ]\" p
- 2 |9 P5 o\" ^% i! ^, l6 V
- def updata(i):2 u7 B* j- C1 n4 M/ \
- req = requests.get("https://www.xxx.com/play/xxx-2-%s.html" % i)
- , Y+ U* R' ^- Z; S$ V$ d6 B6 g. n req.encoding = "utf-8" M7 C\" x( O. {1 k6 `) M
- m3u8 = getmidstring(req.text, "var now=\"", "\"")
- * d% i4 O4 i4 {, I9 k% o% X5 i9 A. o1 R& I' ?8 b% s, p2 j
- html = etree.HTML(req.text)
- 3 K4 I' ~) w* j title = html.xpath("//meta[@name=\"description\"]/@content")[0]4 o+ N+ B. w9 w; X& k! z
- title = getleftstring(title, ",")
- $ k2 O9 |! n% j* F, M\" u( _. a! G5 ^0 A; O print(title)
- }( S- v: ~( n9 p2 z0 n
- & N$ B. H) l; A4 X0 a6 |/ | cmd = "\"%s\" --workDir \"%s\" --saveName \"%s\" --enableDelAfterDone" % (
- - U0 s- l$ e7 T( j( ?\" O: r m3u8,
- * r9 p& J6 w0 e$ c r"F:\xxx",
- * L; A9 c0 M* \ y title)7 L+ V1 z+ G) r
- print(cmd)+ d! S M- m7 ~8 A9 g
- \" P `0 G& _5 Z+ B0 F4 X dll = windll.LoadLibrary("Shell32.dll")1 F% P* N- {/ H% z' D% ~
- print(dll.ShellExecuteW(None,
- 9 {- [5 Y) c! C) a. m4 M6 W "open",
- - @& E2 t Y9 ~9 a r"D:\xxx.exe",
- $ A( G0 O7 Z: l6 o; l2 D cmd, None, 1))
- ( n\" V/ b: o: O [
- 3 L9 i3 |7 P Q) h/ F
- ' T; k6 Z9 B0 _. ]\" b0 A- A/ ddef cycle():5 }: V, F) ^8 u6 ^( G) ?
- for i in range(40): g$ Z5 Z4 q2 {; T1 _ [
- updata(i)7 `) r- o: H4 Z! E9 a% y, `6 V
- , q3 W; F. [7 H: o( T
- * g0 A& x0 m; ]0 ]if __name__ == '__main__':
- # x- Y* H3 t9 M% U5 S hThread = threading.Thread(target=cycle)
- + S$ V& j* a$ M% k% D. M hThread.setDaemon(True)2 ]3 W3 T! y' |0 p! Q
- hThread.start()
- ! H I. P/ M- b hThread.join()
- ( K1 u! Z+ i1 u/ V6 R9 {2 y7 H
3 Z4 @) u# _/ k+ ~5 P* V
: t) ~" m% @2 [% y9 V4 K1 b1 C在线追剧又卡又慢!还不方便,写个Python脚本自动帮我缓存下~
0 P6 [3 }9 Q; g# H3 ?8 g( s
) [; f' ~' A; _8 w
8 q- c; P4 o" u( h5 fPython交流群:1047602540
5 k7 q1 G3 I5 G" J" X" C
9 A# Y3 T2 O1 R& j2 `5 Z) q# w1 V% G8 Z
|
zan
|