Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
tianzhengs committed Nov 22, 2021
1 parent 53e464d commit 26fe719
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@

from cap_denoise import dn

org_id = '172442' # "北京市海淀团区委"

username = os.environ["USERNAME"]
password = os.environ["PASSWORD"]

if not (username and password):
raise Exception("请设置Secret: USERNAME和PASSWORD")


org_id = '172442' # "北京市海淀团区委"
# or check string type
try:
org_id_input = os.environ["ORGID"]
Expand All @@ -37,16 +38,17 @@ def encrypt(t):
return cipher_text.decode()


bjySession = requests.session()
# set session timeout
bjySession.timeout = 5
fake_ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36 Edg/80.0.361.111'
bjySession.headers.update({
"User-Agent": fake_ua, })

url = ''
for _ in range(10):
try:
bjySession = requests.session()
# set session timeout
bjySession.timeout = 5
fake_ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36 Edg/80.0.361.111'
bjySession.headers.update({
"User-Agent": fake_ua, })

r = bjySession.get(url="https://m.bjyouth.net/site/login")
cap_url = "https://m.bjyouth.net" + re.findall(
r'src="/site/captcha.+" alt=', r.text)[0][5:-6]
Expand All @@ -57,7 +59,6 @@ def encrypt(t):
cap_text = ocr.classification(cap)
print(f'Captcha OCR: {cap_text}')
_csrf_mobile = bjySession.cookies.get_dict()['_csrf_mobile']
# TODO: 有时间看一下这个算法
login_password = encrypt(password)
login_username = encrypt(username)
login_r = bjySession.post('https://m.bjyouth.net/site/login',
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


# How to use
1. Fork (+ ~~Star~~)
1. Fork (+ Star)
2. 填写以下SECRET (名称均为大写):

​ (账号密码为登录青春北京的信息,可以在[这里](https://m.bjyouth.net/site/login)测试登录信息)
Expand Down

0 comments on commit 26fe719

Please sign in to comment.