用selenium自动填写调查问卷


# 查看ip是否有用
# driver.get("http://httpbin.org/ip")
# print(driver.page_source)
driver.get("https://www.wjx.cn/m/23272865.aspx")
driver.find_element_by_xpath("//*[@id='div1']/div[2]/div[1]/span/a").click()
for i in range(1, 3):
driver.find_element_by_xpath("//*[@id='div%d']/div[2]/div[1]/span/a" % i).click()
list1 = list(range(3, 46))
del list1[7]
del list1[7]
for i in list1:
driver.find_element_by_xpath("//*[@id='div%d']/div[2]/table/tbody/tr[2]/td[1]/a" % i).click()
driver.find_element_by_xpath("//*[@id='ctlNext']").click()


if __name__ == "__main__":
for i in range(5):
# chromeOptions = webdriver.ChromeOptions()
# 设置代理
# ips = ['119.183.211.171:1245',
# '118.254.79.191:2386',
# '115.153.172.79:1659',
# '111.74.234.4:9756',
# '119.7.218.46:5974',
# ]'''
# chromeOptions.add_argument("--proxy-server=http://" + ips[i])
driver = webdriver.Chrome()
doQuestion()





posted @ 2018-05-10 20:40  Saruka的男朋友  阅读(777)  评论(0编辑  收藏  举报