当前位置:网站首页>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
边栏推荐
猜你喜欢

Shell script learning notes - regular expressions

php+mysql對下拉框搜索的內容修改

Fashion MNIST dataset classification training

Rhcsa day 1 operation

Airtrack cracking wireless network password (Dictionary running method)

Sonic cloud real machine tutorial

Error installing Mongo service 'mongodb server' on win10 failed to start

LeetCode 1450 - 1453

Configuring Apache Web services for servers such as Tianyi cloud

Traversée de l'arbre L2 - 006
随机推荐
Rhcsa day 4 operation
The penultimate K nodes in jz22 linked list
Modify the content of MySQL + PHP drop-down box
JVM class loader
Essential qualities of advanced programmers
Six very 6 computer driver managers: what software is good for driver upgrade? Recommended by the best computer driver management software abroad
AC380V drop 5v12v24v200ma, UHV non isolated chip IC scheme
Solve the problem that PowerShell mining occupies 100% of cpu7 in win7
Codeforces round 784 (Div. 4) (a - H)
JVM runtime data area (I)
[hcip] detailed explanation of six LSAS commonly used by OSPF
重大危险源企业如何保障年底前完成双预防机制数字化建设任务
JZ35 replication of complex linked list
Log cutting - build a remote log collection server
Step principle of logical regression in machine learning
Classification of technology selection (2022)
Liunx foundation - zabbix5 0 monitoring system installation and deployment
国产轻量级看板式Scrum敏捷项目管理工具
Win view port occupation command line
Rhcsa day 3 operation