python问卷星登录_Python+Selenium⾃动刷问卷星问卷importtimeimportrandomfrom selenium importwebdriverdefautoSelect():#将问卷星⽹站放在下⾯
<('www.wenjuan/s/IFNFni')
key_1= str(random.randint(1, 4))
list1= ['计算机', '会计', '汽修', '幼师', '建筑', '⼯商']
key_2= list1[random.randint(0,5)]#单选题,因为和后⾯的题有逻辑关系,记下随机值key_1
xpath1 = '//*[@id="question_5e647ab73631f215eee34177"]/div[2]/div[3]/div[1]/div[%s]/label[1]' %key_1
answer_1=driver.find_elements_by_xpath(xpath1)[0]
answer_1.click()#2
for i in range(random.randint(2, 5)):
xpath2= '//*[@id="question_5e647ab73631f215eee34178"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 6)
answer_2=driver.find_elements_by_xpath(xpath2)[0]
answer_2.click()#3
xpath3 = '//*[@id="question_5e647ab73631f215eee34179"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 5)
answer_3=driver.find_elements_by_xpath(xpath3)[0]
answer_3.click()#4
xpath4 = '//*[@id="question_5e647ab73631f215eee3417a"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 5)
answer_4=driver.find_elements_by_xpath(xpath4)[0]
answer_4.click()#5
xpath5 = '//*[@id="question_5e647ab73631f215eee3417b"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 5)
answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#6
xpath5 = '//*[@id="question_5e647ab73631f215eee3417c"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 4)
answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#7
xpath5 = '//*[@id="question_5e647ab73631f215eee3417d"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 6)
answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#8
xpath5 = '//*[@id="question_5e647ab73631f215eee3417e"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 4)
answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#9
xpath5 = '//*[@id="question_5e647ab73631f215eee3417f"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 4)
answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#10
xpath5 = '//*[@id="question_5e647ab73631f215eee34181"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 5) answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#12
xpath5 = '//*[@id="question_5e647ab73631f215eee34182"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 4) answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#13
for i in range(1,4):
xpath5= '//*[@id="question_5e647ab73631f215eee34183"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 5) answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#14
xpath5 = '//*[@id="question_5e647ab73631f215eee34184"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 3) answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#15
for i in range(2, 4):
xpath5= '//*[@id="question_5e647ab73631f215eee34185"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 4) answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#16
driver.find_element_by_id("5e647ab73631f215eee341d0").send_keys(key_2)#17
xpath5 = '//*[@id="question_5e647ab73631f215eee34187"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 4) answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#18
xpath5 = '//*[@id="question_5e647ab73631f215eee34188"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 5) answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#19
xpath5 = '//*[@id="question_5e647ab73631f215eee34189"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 2) answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#20
for i in range(0, 5):
xpath5= '//*[@id="question_5e647ab73631f215eee3418a"]/div[2]/div[3]/div[1]/div[%s]/label[1]' % random.randint(1, 6) answer_5=driver.find_elements_by_xpath(xpath5)[0]
answer_5.click()#21
submit = driver.find_elements_by_id('next_button')[0] submit.click()
time.sleep(1)
driver.quit()if __name__ == '__main__':#循环4次
for index in range(1, 5):
random pythondriver=webdriver.Chrome()
autoSelect()
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论