├── .idea
├── .gitignore
├── Stage1stHelper.iml
├── inspectionProfiles
│ └── profiles_settings.xml
├── misc.xml
└── modules.xml
├── LICENSE
├── README.md
├── config.json
├── member.py
└── start.py
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Datasource local storage ignored files
5 | /dataSources/
6 | /dataSources.local.xml
7 | # Editor-based HTTP Client requests
8 | /httpRequests/
9 |
--------------------------------------------------------------------------------
/.idea/Stage1stHelper.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Fungx
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Stage1st巨魔助手
2 |
3 | **自动登录账号挂权限,方便 ~~爱讨论、钓鱼、巨魔~~**
4 |
5 |
6 |
7 | ## 使用方法
8 | 1. 修改config.json中的配置,refresh_time为每次刷新的时间间隔,测试过300s不会被离线。members中可以填入多个账号,可以按需要添加。
9 | ```json
10 | {
11 | "refresh_time": 300,
12 | "members": [
13 | {
14 | "username":"你的用户名",
15 | "password":"你的密码"
16 | },
17 | {
18 | "username":"你的用户名2",
19 | "password":"你的密码2"
20 | }
21 | ]
22 | }
23 | ```
24 | 2. 执行start.py。
25 | ```shell
26 | python start.py
27 | ```
28 |
--------------------------------------------------------------------------------
/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "refresh_time": 300,
3 | "members": [
4 | {
5 | "username":"",
6 | "password":""
7 | }
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/member.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import logging
3 | import re
4 |
5 | logger = logging.getLogger(__name__)
6 |
7 |
8 | class Member:
9 | def __init__(self, username, password):
10 | self.is_login = False
11 | self.username = username
12 | self.password = password
13 | self.session = requests.Session()
14 |
15 | def login(self, on_success, on_failure):
16 | data = self.session.post(
17 | "https://bbs.saraba1st.com/2b/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1",
18 | data={"username": self.username, "password": self.password},
19 | ).text
20 | if "https://bbs.saraba1st.com/2b/./" in data:
21 | logger.info(self.username + ": 登陆成功")
22 | self.session.headers.update(
23 | {
24 | "user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
25 | "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
26 | "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",
27 | "Accept-Encoding": "gzip, deflate, br",
28 | "Connection": "keep-alive",
29 | "referer": "https://bbs.saraba1st.com/2b/forum-75-1.html",
30 | }
31 | )
32 | self.is_login = True
33 | on_success()
34 | else:
35 | logger.warning(data)
36 | on_failure()
37 |
38 | # 发请求保持在线
39 | def action(self):
40 | if not self.is_login:
41 | return
42 | # 获取用户id
43 | userid = re.findall('.*(?=%7C)', self.session.cookies.get('B7Y9_2132_lastcheckfeed'))[0]
44 | # 构造主页url
45 | home_url = "https://bbs.saraba1st.com/2b/home.php?mod=space&uid={}&do=profile&from=space".format(userid)
46 | data = self.session.get(home_url).text
47 | # 访问成功
48 | if "个人资料" in data:
49 | score = re.findall("(?<=积分)[0-9]*", data)[0]
50 | online_time = re.findall("[1-9]* 小时", data)[0]
51 | logger.info("{}: 刷新 积分: {} 在线时间: {}".format(self.username, score, online_time))
52 |
--------------------------------------------------------------------------------
/start.py:
--------------------------------------------------------------------------------
1 | import json
2 | import logging
3 | import time
4 | import os
5 | from member import Member
6 |
7 | logging.basicConfig(
8 | level=logging.INFO,
9 | format="%(asctime)s - %(levelname)s: %(message)s",
10 | datefmt="%Y-%m-%d %H:%M:%S",
11 | )
12 | logger = logging.getLogger(__name__)
13 |
14 | config = json.load(open('./config.json', 'r', encoding='utf-8'))
15 | refresh_time = config['refresh_time']
16 | member_list = []
17 | # 保存登录成功的对象
18 | for i in config['members']:
19 | member = Member(i['username'], i['password'])
20 | member.login(on_success=lambda: member_list.append(member),
21 | on_failure=lambda: logger.warning(i['username'] + ' 登录失败'))
22 | # 没有登录成功的账号
23 | if not member_list:
24 | logger.error('没有登录成功的账号,即将退出')
25 | os.system('pause')
26 | exit(1)
27 |
28 | while True:
29 | for i in member_list:
30 | i.action()
31 | time.sleep(refresh_time)
32 |
--------------------------------------------------------------------------------