环境:
- Windows 10
- Python 3.7
说明:
关于登录问题:
# 账号 改成自己的
username = '123456789'
# 密码 改成自己的
UserPwd = '********'
本地cookie文件
运行后会生成cookie_index.txt与cookie_login.txt文件,里面存放着登录需要的cookie信息。
签到:
复制字符串到https://www.bejson.com/enc/urlencode/解码并修改相应的中文再编码
qiang_data = 'InternStateId=4&interContent=%E6%96%87%E6%9C%AC%E5%86%85%E5%AE%B9&logImg=&posAddress=%E5%9C%B0%E5%9D%80&posLong=%E7%BB%8F%E7%BA%AC%E5%BA%A6&posLati=%E7%BB%8F%E7%BA%AC%E5%BA%A6&locationType=1&ArticleId=0'
代码
# coding=utf-8
'''
闯越顶岗实习签到程序
'''
import requests
import sys
import json
import win32api
import win32con
import os
import _thread
import datetime
cookie_login = {
}
cookie_index = {
}
# 登录
def get_login():
global cookie_login
global cookie_index
login_headers = {
'Host': 'hl.cydgsx.com',
'Connection': 'keep-alive',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Origin': 'https://hl.cydgsx.com',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Referer': 'https://hl.cydgsx.com/m/Home/Index',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7'
}
# 账号
username = '123456789'
# 密码
UserPwd = '********'
login_data = 'username={}&UserPwd={}&wxInfo=&openid='.format(
username, UserPwd)
login = requests.post(
'https://hl.cydgsx.com/m/Home/CheckLoginJson', headers=login_headers, data=login_data)
cookie_login = requests.utils.dict_from_cookiejar(login.cookies)
index_headers = {
'Host': 'hl.cydgsx.com',
'Connection': 'keep-alive',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-User': '?1',
'Sec-Fetch-Dest': 'document',
'Referer': 'https://hl.cydgsx.com/m/Home/Index',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,ja;q=0.7',
'Cookie': 'LoginUser_Id={0}; loginUserName={1}'.format(cookie_login['LoginUser_Id'], cookie_login['loginUserName'])
}
get_index = requests.get