Conditions for running code
- Google browser
- Download the corresponding version of your Google browser chromedriver.exe Unzip it to your python.exe Under the table of contents
- python3 edition ( I use it 3.7)
- stay python Installed in the selenium package
- The question type of the questionnaire is single choice or multiple choice Note that each option takes a line
Complete the above requirements and you can run it , Here's the whole code
from selenium import webdriver import random import time def select(x,y): a = '//*[@id="divquestion%d"'%(x)+']/ul/li[%d'%(y)+']/label' driver.find_element_by_xpath(a).click() time.sleep(random.randint(0, 1)) def select_r(x,y): num = random.randint(1, y) a = '//*[@id="divquestion%d"' % (x) + ']/ul/li[%d' % (num) + ']/label' driver.find_element_by_xpath(a).click() time.sleep(random.randint(0, 1)) def mulity_select(x,y,z): num = random.sample(range(1, y+1), z) for i in range(z): a = '//*[@id="divquestion%d"' % (x) + ']/ul/li[%d' % (num[i]) + ']/label' driver.find_element_by_xpath(a).click() time.sleep(random.randint(0, 1)) for i in range(10):# Set the number of times to fill in I am here 10 The representative filled out the questionnaire ten times driver = webdriver.Chrome() driver.get('https://www.wjx.cn/jq/X.aspx')# Fill in your questionnaire url select_r(1,4)# Represents a random selection problem 1 One of the four options for select(3,3)# Direct choice question 3 The third option of mulity_select(18,6,4)# It means a choice question 18 in 6 Of the options 4 An option driver.find_element_by_xpath('//*[@id="submit_button"]').click() print(' The first '+str(i+1)+' Fill in successfully ') time.sleep(2) driver.quit()
When running, modify the parameters in the code according to your questionnaire
Set the number of times to fill out the questionnaire ( It is recommended not to set too many at one time )

Change this to the URL of your questionnaire

Here are my three functions , It should be noted that the first parameter of the function is not the order of your questionnaire questions , Here we need to use the browser's developer tools to see , The detailed process is later

How to get the serial number of the question ?
Go to your questionnaire page , Click developer tools

Click here after entering

On the basis of completing the previous step , Click any of the options in the questionnaire on the left , For example, I clicked “ Woman ” After this option , On the right side “ Woman ” there q2_2 in first 2 It's the serial number of the question we're looking for , Back one 2 For options 2. Put the problem number in the function , The program can find the corresponding problem

Because my questionnaire only has multiple choice questions and single choice questions , So I only wrote about these two parts . If you understand the program , You can write it yourself to meet your needs .
Be careful : If you're looking for python Well paid jobs . I suggest you write more about real enterprise projects and accumulate experience . Or you won't find a job , Of course, a lot of people have never been in a business , How can there be project experience ? So you have to find more enterprise projects and practice more . If you're lazy and don't want to find , You can also enter my Python Circle of communication :1156465813. There are some real enterprise project cases that I have written before in the group file . You can take it to study , If you don't understand, you can find me in your skirt , I'll answer you patiently when I have time .
The following is useless , For this blog to be crawled by search engines
(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)
python What is it Zero basis to learn python How long will it take? python Why is it called a reptile
python Novice reptile tutorial python Crawler universal code python How do reptiles make money
python Basic course Web crawler python python Classic examples of reptiles
python Reptiles
(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)(* ̄︶ ̄)
The above is useless , For this blog to be crawled by search engines