自动刷投票软件代码如何编写?
今天我来给大家说下自动刷投票软件代码的编写,因为有很多参加投票活动的小伙伴们不了解自动刷投票软件的代码,有些人甚至是花费了很多的时间精力,想要写出一款自动刷投票软件,但是对于一些技术不过硬的小伙伴来说,相对是比较难的,那么今天我给大家说的整个自动刷投票软件的代码相对而言比较简洁一些,下面我们来看下吧
# coding:utf-8
"""
需要安装包
pip install -u selenium
需要安装浏览器
firefox
"""
from selenium import webdriver
import time
import sys
base_url = "******************"
def tp():
print u"欢迎刷票!"
print u"输入数字,输入错误程序就挂!"
gender = raw_input(u"请输入性别: 男1, 女2\t".encode(sys.stdout.encoding))
clothes = raw_input(u"请输入衣服:服装1, 服装2\t".encode(sys.stdout.encoding))
color = raw_input(u"请输入颜色:黑色1, 白色2,红色3\t".encode(sys.stdout.encoding))
print u"好的好的,开始刷拉!\n Ctrl+C 退出程序!"
count = 0
try:
while True:
browser = webdriver.Firefox()
browser.get(base_url)
# 模拟选项
time.sleep(10)
try:
# print browser.title
assert u"毕业季来啦" in browser.title
except AssertionError:
print u'已刷票{}次!'.format(count)
print u'抱歉,程序出错,请稍后再试'
exit(0)
browser.find_element_by_xpath("//div[@id='div1']/div[2]/div[{0}]/span/a".format(int(gender))).click()
browser.find_element_by_xpath("//div[@id='div2']/div[2]/div[{0}]/span/a".format(int(clothes))).click()
browser.find_element_by_xpath("//div[@id='div4']/div[2]/div[{0}]/span/a".format(int(color))).click()
browser.find_element_by_id('ctlNext').click()
time.sleep(10)
try:
# print browser.title
assert u"我刚刚" in browser.title
except AssertionError:
print u'已刷票{}次!'.format(count)
print u'抱歉,程序出错,请稍后再试'
exit(0)
browser.quit()
count += 1
except KeyboardInterrupt:
print u'已刷票{}次,再见!'.format(count)
exit(0)
if __name__ == '__main__':
tp()
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
截图:
版权申明:本篇文章属于原创,转载请注明出自微信投票网。原文地址: https://www.aivote.com/12998.html