forked from garyvalue/javbus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
javbus.py
69 lines (63 loc) · 2.28 KB
/
javbus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import requests, json, time, os, sys
sys.path.append('.')
requests.packages.urllib3.disable_warnings()
try:
from pusher import pusher
except:
pass
from lxml import etree
cookie = os.environ.get("cookie_javbus")
def run(*arg):
msg = ""
s = requests.Session()
s.headers.update({'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0'})
# 签到
url = "https://www.busjav.fun/forum/home.php?mod=spacecp&ac=credit"
headers = {
'authority': 'www.busjav.fun',
'method': 'GET',
'path': '/forum/home.php?mod=spacecp&ac=credit',
'scheme': 'https',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0',
#'Connection' : 'keep-alive',
#'Host' : 'www.right.com.cn',
'Upgrade-Insecure-Requests' : '1',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Language' : 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
'Accept-Encoding' : 'gzip, deflate, br',
'Cookie': cookie,
'referer': 'https://www.busjav.fun/forum/home.php?mod=spacecp'
}
try:
r = s.get(url, headers=headers, timeout=120)
# print(r.text)
if '每天登录' in r.text:
h = etree.HTML(r.text)
data = h.xpath('//tr/td[6]/text()')
msg += f'签到成功或今日已签到,最后签到时间:{data[0]}'
else:
msg += '签到失败,可能是cookie失效了!'
pusher(msg)
except:
msg = '无法正常连接到网站,请尝试改变网络环境,试下本地能不能跑脚本,或者换几个时间点执行脚本'
return msg + '\n'
def main(*arg):
msg = ""
global cookie
if "\\n" in cookie:
clist = cookie.split("\\n")
else:
clist = cookie.split("\n")
i = 0
while i < len(clist):
msg += f"第 {i+1} 个账号开始执行任务\n"
cookie = clist[i]
msg += run(cookie)
i += 1
print(msg[:-1])
return msg[:-1]
if __name__ == "__main__":
if cookie:
print("----------巴士论坛开始尝试签到----------")
main()
print("----------巴士论坛签到执行完毕----------")