Last active
November 17, 2019 21:31
-
-
Save menyf/fa651c68fc03a3f04cd1f611e3687380 to your computer and use it in GitHub Desktop.
Credit to: https://clarka.github.io/1p3c-auto-punch-in/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import re | |
import json | |
class AutoPunch: | |
def __init__(self, username, pwd): | |
self.username = username | |
self.pwd = pwd | |
self.login_url = 'https://www.1point3acres.com/bbs/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1' | |
self.punch_url = 'https://www.1point3acres.com/bbs/plugin.php?id=dsu_paulsign:sign&operation=qiandao&infloat=1&sign_as=1&inajax=1' | |
self.session = requests.Session() | |
self.headers = { | |
'origin': 'https://www.1point3acres.com', | |
'referer': 'https://www.1point3acres.com/bbs/', | |
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36', | |
} | |
def login(self): | |
res = self.session.post(self.login_url, | |
headers=self.headers, | |
data={ | |
'username': self.username, | |
'password': self.pwd, | |
'quickforward': 'yes', | |
'handlekey': 'ls' | |
}) | |
return res | |
def get_formhash(self): | |
res = self.session.get('https://www.1point3acres.com/bbs/', headers=self.headers) | |
result = re.search('dsu_paulsign:sign&(.{8})', res.text) | |
if result: | |
return result.group(1) | |
# post body里的qdxq=签到心情,todaysay=今日想说的话。 | |
def punch(self, formhash): | |
res = self.session.post(self.punch_url, | |
headers=self.headers, | |
data={ | |
'formhash': formhash, | |
'qdxq': 'kx', | |
'qdmode': 2, | |
'todaysay': 'im the best guy', | |
'fastreply': 0 | |
}) | |
print(account['id'] + ' status: ' + str(res.status_code)) | |
if __name__ == '__main__': | |
accounts = [ | |
{ | |
"id": "username", | |
"password": "encoded_password" | |
} | |
] | |
for account in accounts: | |
ap = AutoPunch(account['id'], account['password']) | |
ap.login() | |
formhash = ap.get_formhash() | |
if formhash: | |
ap.punch(formhash) | |
else: | |
print(account['id'] + ' 今日已签到') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment