当前位置:网站首页>Guangcheng cloud service can fill in a daily report regularly every day
Guangcheng cloud service can fill in a daily report regularly every day
2022-04-23 02:53:00 【Little fat man who loves bug】
be based on python Realize the daily report
The school applet has been updated , So our code needs to be changed a little . I'll grab the bag again , First open our Charles, Open the Guangcheng cloud service that will share us with the file transfer assistant .
Through some text information, we can know that this is our small program that needs to capture packets . This time, the small program of the school has been greatly changed , The domain names have been changed . But for us, it doesn't affect , The principle is the same .
The principle of automatic filling is to simulate normal users sending data packets to their background data . The web page that our normal users visit is through get Request to get data , and , We submit data with post request , What we're going to do is use post Request to send form data . If we try to submit data once, we will see a URL Pop it out .
This packet , Contains the form data we need to submit , also URL( Commonly known as link ).
My source code has been written
# -*- coding: utf8 -*-
import requests
import json
# You can change it to your own token
token = "8966a1aa7508438fa384fc02767d5835"
studentinfo = {
"version": "20220409",
"name": " handsome young man ",# Fill in the name
"pwd": "12345678",# Fill in the student number
"openid": "openid",
"subscription": "accept"
}
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat"
}
def getuid(info):
login_url = "https://jsd.hc-web.cn/api/index/login"
return int(json.loads(requests.post(login_url, info, verify=False, headers=headers).text)["data"]["user"]["id"])
def putdata(uid):
put_url = "https://jsd.hc-web.cn/api/index/putDay"
data = {
"version": 20220409,
"uid": uid,
"is_campus": " no ",
"campus": " Internship abroad without returning to school ",
"nowaddress": " Currently in Guangzhou ",
"nowaddressinfo": "undefined",
"region_address": "undefined",
"phone": "15218128768",
"fever": 2,
"feverinfo": "undefined",
"feverinfo1": "undefined",
"feverinfo2": "undefined",
"feverinfo3": "undefined",
"jie": "5",
"jie1": "undefined",
"jie3": "undefined",
"jie4": "undefined",
"jie5": "undefined",
"jie6": "undefined",
"jie7": "undefined",
"jie8": "undefined",
"jie9": "undefined",
"jie10": "undefined",
"jie11": "undefined",
"plan": 2,
"planaddress": "undefined",
"risk_area": " Low risk areas ",
"risk_area_address": "undefined",
"jkcode": " Green code ",
"new_status": " At home ",
"status_remark": " Online practice ",
"company" :"undefined",
"city":"undefined",
"other_status":"undefined",
}
response = json.loads(requests.post(put_url, data, verify=False).text)
result = True if response["msg"] == " Saved successfully " else False
return result
def server_push(result):
push_url = "http://www.pushplus.plus/send?"
title = " Yes , The daily report has been completed " if result == True else " Mama ah , The daily newspaper failed "
oneyan = "<p>" + requests.get("https://v1.hitokoto.cn/?c=f&encode=text", verify=False).text + "</p>";
data = {
"token": token,
"title": title,
"content": oneyan + '',
"template": "html"
}
response = json.loads(requests.post(push_url, data, verify=False, headers=headers).text)
print(response)
def run():
if token == "":
putdata(getuid(studentinfo))
return " A daily report of success , However, wechat notification push has not been started !"
else:
server_push(putdata(getuid(studentinfo)))
return " A daily report of success , Wechat notification has been pushed !"
def main_handler(event, context):
return run()
# if __name__ == '__main__':
# run()
Use Tencent cloud function to realize daily automatic filling
If you don't apply for Tencent cloud account here, you can apply for one , Baidu cloud is OK , I use Tencent cloud for demonstration here ( It's all free ). Click on the top right console -- Select the cloud product in the upper left corner -- Select cloud function .
Here we choose to create -- Choose to start from scratch (helloworld Templates )-- Operating environment selection python3.6 edition . Delete the code inside , Copy and paste the code above .
Next is the most important link , Trigger . We need to be regular every day 10 Click trigger to run the program .
Select custom trigger , Here we can't choose the ten point trigger program to run , We also customize a .
Cron The expression means every day 10 Click to trigger a program run , In this way, our program can run regularly every day .
Click deploy and test , Success proves that the code is OK , That's pretty much it .
Here's another little detail , Namely token, The purpose is to tell us whether the program runs successfully or fails . Failure proves that their data has been updated . Use token It's also very simple. , Focus on one pushplus Push plus A public of , Log in . Click profile , Find the development settings . There's yours in it token, You can also set up one yourself . In this way, once the program runs, your mobile phone will receive a message . The effect is as follows :
版权声明
本文为[Little fat man who loves bug]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220715077016.html
边栏推荐
- Face longitude:
- Essential qualities of advanced programmers
- Modify the content of MySQL + PHP drop-down box
- [wechat applet] set the bottom menu (tabbar) for the applet
- First day of rhcsa
- Centos7 install MySQL 8 0
- Shell script learning notes -- shell operation on files sed
- Leangoo brain map - shared multi person collaborative mind mapping tool
- Linux redis - redis ha sentinel cluster construction details & redis master-slave deployment
- The usage of case when and select case when is very easy to use
猜你喜欢
Encapsulate components such as pull-down menu based on ele
重大危险源企业如何保障年底前完成双预防机制数字化建设任务
The way to conquer C language
Linux redis - redis database caching service
Rhcsa day 1 operation
Kubernetes - Introduction to actual combat
Flink learning (XI) watermark
grain rain
Servlet template engine usage example
Android 高阶面试必问:全局业务和项目的架构设计与重构
随机推荐
基于多态的职工管理系统源码与一些理解
JS using the parameters of art template
Source code and some understanding of employee management system based on polymorphism
How to build an integrated industrial Internet plus hazardous safety production management platform?
MySQL / SQL Server判断表或临时表存在则删除
Android 高阶面试必问:全局业务和项目的架构设计与重构
Interim summary (Introduction + application layer + transportation layer)
C语言 171. 最近回文数
Microservices (distributed architecture)
win查看端口占用 命令行
Résumé du gestionnaire de projet du système d'information Chapitre VI gestion des ressources humaines du projet
ROP Emporium x86_ 64 7 ~ 8 questions
Airtrack cracking wireless network password (Dictionary running method)
Android high-level interview must ask: overall business and project architecture design and reconstruction
eventBus
JZ22 链表中倒数最后k个结点
Log4j知识点记录
【工欲善其事必先利其器】论文编辑及文献管理(Endnote,Latex,JabRef ,overleaf)资源下载及使用指南
Devil cold rice 𞓜 078 devil answers the market in Shanghai and Nanjing; Communication and guidance; Winning the country and killing and screening; The purpose of making money; Change other people's op
Modification du contenu de la recherche dans la boîte déroulante par PHP + MySQL