[Python] 纯文本查看 复制代码
import urllib.request as ur
import ssl
import json
context = ssl._create_unverified_context()
def qiandao(token):
data_s={
'country': '中国',
'address': '湖北省 · 中国农业银行',
'province': '湖北省',
'city': '湖北省',
'latitude': '30.336959',
'type': 'START',
'longitude': '113.429182'
}
url = 'https://api.moguding.net:9000/attendence/clock/v1/save'
headers = {
'Authorization': token,
'Content-Type': 'application/json; charset=UTF-8'
}
data=json.dumps(data_s)
requests=ur.Request(url=url,data=data.encode("utf-8"),headers=headers)
try:
if json.loads(ur.urlopen(requests,context=context).read().decode())['code']==200:
print('签到成功')
else:
print('如果签到失败就会发邮件')
'''
这里写发送邮件的方法
'''
pass
except Exception as e:
pass
def logo():
logo_data = {
"phone":input('请输入蘑菇钉账号'),
"password":input('请输入蘑菇钉密码'),
"loginType":"android"
}
request_logo = ur.Request(
url = 'https://api.moguding.net:9000/session/user/v1/login',
data =json.dumps(logo_data).encode(),
headers = {
'Content-Type':'application/json; charset=UTF-8'
}
)
try:
token = json.loads(ur.urlopen(request_logo,context=context).read().decode())['data']['token']
if token:
qiandao(token)
except Exception as e:
datad = '<urlopen error Remote end closed connection without response>'
if datad==str(e):
print('网络连接超时')
else:
print('账号或密码输入错误')
pass
if __name__ == '__main__':
logo() |