When leaving the laboratory due to coronavirus, it is necessary to enter the entry / exit time of the day on Google form.
It is a project to make it fully automatic because it is troublesome to do it every day and there are many forgetting to input.
When entering or leaving the room, a person is identified by face recognition using a camera, and that person's information is automatically entered / sent using Google form.
This time, I summarized the automatic input / transmission part.
Google form URL (example) (https://docs.google.com/viewform?)
By adding "usp = pp_url" after the view form, we will notify you that there is pre-input.
Next, since there is a number that identifies each question in the form, look for the question div on the verification screen of Chrome, and look for the following number in the second layer.
When you find the number, add the parameter in the form of entry.number = answer content
.
If you connect in the following form, it's ok
https://~/viewform?usp=pp_url&entry.1534939278=Test Taro&entry.511939456='+student_id
In the case of a laboratory, you need to enter your name, student ID number, and entry / exit date and time. The identification number was as follows.
Name: 208832475 Student ID number: 913668226 Entering and leaving the room: 1243542068 Remarks: 1484015294
Now that I know the identification number, I will actually write the program Su.
In order to increase versatility, the url and identification number that depend on each Google form are summarized in cfg.json
.
form_url
is beforeviewform?
.
cfg.json
{
"form_url": "https://docs.google.com/forms/6_m-WWhmzw/",
"entry": {
"name": 2005620554,
"id": 1045781291,
"time": 1065046570
},
"output":{
"name": "Test Taro",
"id": "00110220404",
"time": "2020/11/7 13-19"
}
}
form_.py
fname = "cfg.json"
with open(fname, "r") as f:
cfg = json.load(f)
#Creating an answer form
params = {"entry.{}".format(cfg["entry"][k]): cfg["output"][k] for k in cfg["entry"].keys()}
res = requests.get(cfg["form_url"] + "formResponse", params=params)
#Check if you can answer
if res.status_code == 200:
print("Done!")
else:
res.raise_for_status()
print("Error")
Now you can send automatically. (Only if you don't need to log in to your google account)
I want to automatically reply to Google Form at 5 o'clock every morning --Qiita
Win a fucking survey with Google Form auto-answer bot (Python3) --free (malloc (sizeof (MRM)));