python实现短信发送

简介: python实现短信发送,近期老收到自称自己是京东金融的私人电话,骗取钱财,我直接一顿臭骂,他还还口,所以就有了这个短信息发给他。。、。

代码如下:

# coding=utf-8
"""
    @project: automation_tools
    @Author:gaojs
    @file: test010.py
    @date:2022/10/19 16:12
    @blogs: https://www.gaojs.com.cn
"""
import time

import requests
from faker import Factory


class SMS:
    """短信发送功能"""

    def __init__(self, account, password):
        """account:APIID(用户中心【验证码通知短信】-【产品纵览】查看)
           password:APIKEY(用户中心【验证码通知短信】-【产品纵览】查看)
           self.url:接口请求地址
           接口网站:https://www.ihuyi.com/
        """
        self.accout = account
        self.passwod = password
        self.url = 'https://106.ihuyi.com/webservice/sms.php?method=Submit'
        randon_ua = Factory.create()
        self.ua = randon_ua.user_agent()

    def send_sms(self, mobile, content):
        """
            发短信
            :param mobile: 手机号
            :param content: 短信内容
            :return:None
        """
        headers = {
            "Content-type": "application/x-www-form-urlencoded",
            "Accept": "text/plain",
            "User-Agent": self.ua
        }

        data = {'account': self.accout,
                'password': self.passwod,
                'mobile': mobile,
                'content': content
                }
        # 发起请求:
        response = requests.post(self.url, headers=headers, data=data)
        print(response.content.decode())


if __name__ == '__main__':
    sms = SMS('xxxxxxxxx', 'xxxxxxxxxxxxxxxxxx')
    for i in range(3):
        time.sleep(2)
        print(f"********************* 短信轰炸第 {i + 1} 次成功!!!")
        sms.send_sms('1380000000', '您的验证码是:8888。 请不要把验证码泄露给其他人。')

image-1667209479333

相关文章
|
4月前
|
安全 Linux Shell
Python 动态更新Linux系统root账号密码并发送通知短信
Python 动态更新Linux系统root账号密码并发送通知短信
39 0
|
1月前
|
开发框架 Java .NET
闪速码短信Python接口SDK
闪速码短信Python接口SDK
66 4
|
3月前
|
存储 Shell API
Python 自动化指南(繁琐工作自动化)第二版:十八、发送电子邮件和短信
Python 自动化指南(繁琐工作自动化)第二版:十八、发送电子邮件和短信
Python print() 打印两个 list ,实现中间换行
Python print() 打印两个 list ,实现中间换行
|
Python
Python实现因子分析(附案例实战)
Python实现因子分析(附案例实战)
1039 0
Python实现因子分析(附案例实战)
|
12月前
|
存储 开发工具 Python
七牛云 发送短信报错-Python
(None, _ResponseInfo__response:None, exception:'Auth' object has no attribute 'qiniu_headers', status_code:-1, text_body:None, req_id:None, x_log:None, error:'Auth' object has no attribute 'qiniu_headers'
七牛云 发送短信报错-Python
|
监控 小程序 网络安全
Python3利用Twilio(国际)以及腾讯云服务(国内)免费发送手机短信
短信服务验证服务已经不是什么新鲜事了,但是免费的手机短信服务却不多见,本次利用Python3.0基于Twilio和腾讯云服务分别来体验一下国际短信和国内短信接口。
Python3利用Twilio(国际)以及腾讯云服务(国内)免费发送手机短信
|
JSON 区块链 数据格式
Python实现一个简单的区块链
本文介绍如何用Python实现一个简单的区块链。
482 0
|
存储 数据安全/隐私保护 计算机视觉
python 实现pacs功能 推送下拉影像
python 实现dcmtk关联pacs功能 推送下拉影像
229 0
python 实现pacs功能 推送下拉影像
|
算法 大数据 Python
Leedcode 每日一练 搜索二维矩阵Ⅰ Python实现
Leedcode 每日一练 搜索二维矩阵Ⅰ Python实现
122 2
Leedcode 每日一练 搜索二维矩阵Ⅰ Python实现