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

相关文章
|
2月前
|
安全 Linux Shell
Python 动态更新Linux系统root账号密码并发送通知短信
Python 动态更新Linux系统root账号密码并发送通知短信
46 0
|
2月前
|
存储 API 数据库
使用Python和Twilio通过短信通知主持视频办公时间。
使用Python和Twilio通过短信通知主持视频办公时间。
|
2月前
|
API 开发工具 开发者
PYTHON运行阿里云的短信发送程序报错
图片链接指向一个阿里云开发者生态的图片,内容可能显示了一个关于使用Python SDK调用API发送短信时遇到的错误。错误可能涉及主账号和子账号ID。问题可能是由于缺少环境变量配置导致的。代码基于Python 2.0版本。总结:SDK调用出错,疑因环境变量未配置,影响了账号ID的识别。
|
2月前
|
开发工具 Python
【python】如何通过python来发送短信
【python】如何通过python来发送短信
|
2月前
|
开发框架 Java .NET
闪速码短信Python接口SDK
闪速码短信Python接口SDK
83 4
|
2月前
|
存储 Shell API
Python 自动化指南(繁琐工作自动化)第二版:十八、发送电子邮件和短信
Python 自动化指南(繁琐工作自动化)第二版:十八、发送电子邮件和短信
73 0
|
2月前
|
程序员 Python
小项目|30行Python代码,发短信给你的心里人!
小项目|30行Python代码,发短信给你的心里人!
小项目|30行Python代码,发短信给你的心里人!
|
9月前
|
Python
【Python】对接短信接口
【Python】对接短信接口
80 0
|
Python
Python实现因子分析(附案例实战)
Python实现因子分析(附案例实战)
1261 0
Python实现因子分析(附案例实战)
Python print() 打印两个 list ,实现中间换行
Python print() 打印两个 list ,实现中间换行

相关实验场景

更多