8行python代码领取联通青啤活动流量30MB.2021-1-13修

    科技2024-05-22  73

    # 联通青啤活动流量领取 import urllib.request # http post方法 传递参数 (提交form表单) 联通手机号 = input('请输入一个联通手机号:') # 获取短信验证码 参数 = urllib.parse.urlencode({'phoneVal': 联通手机号, 'type': 21}) 参数 = 参数.encode() urllib.request.urlopen('https://m.10010.com/god/AirCheckMessage/sendCaptcha', 参数) # http get方法 传递参数 短信验证码 = input('请输入收到的验证码:') 统一资源定位符 = 'https://m.10010.com/god/qingPiCard/flowExchange?number=%s&type=21&captcha=%s' % (联通手机号, 短信验证码) urllib.request.urlopen(统一资源定位符)

    测试环境: win xp sp3 , python3.4.4

    所用到的联通链接参见自: https://www.52pojie.cn/forum.php?mod=viewthread&tid=1195947&highlight=%C1%AA%CD%A8

     

    上面8行主要内容的基础上再加入一点点内容:

    # 联通青啤活动流量领取 """ 每次领取30MB,每天最多领取3次, 每月最多领取10次,每次领取的流量有效期为3个月(含当月), 每次间隔不少于60秒,活动终止时间未知 """ import urllib.request import time # 非联通手机号无法参加此活动,携号转网的大部分无发参加此活动 def 验证运营商(手机号): id3 = 手机号[0:3] id4 = 手机号[0:4] 移动 = \ [134, 135, 136, 137, 138, 139, 150, 151, 152, 157, 158, 159, 182, 183, 184, 187, 188, 147, 178, 1705] 联通 = [130, 131, 132, 155, 156, 185, 186, 145, 176, 1709] 电信 = [133, 153, 180, 181, 189, 177, 1700] if (id3 in str(移动)) or (id4 in str(移动)): return "移动" elif (id3 in str(联通)) or (id4 in str(联通)): return "联通" elif (id3 in str(电信)) or (id4 in str(电信)): return '电信' else: return 0 def 验证联通手机号(手机号): 无效长度 = len(手机号) != 11 if 无效长度: print("手机号应当是11位数字,请重新输入一个联通手机号.") 运行次数() else: 运营商 = 验证运营商(手机号) if 运营商: print( ''' 运营商 : {} 手机号 : {} 将通过短信向您的手机发送验证码 '''.format(运营商, 手机号)) else: print("确认手机号是否正确,再次输入.") 运行次数() def 短信验证(联通手机号): 参数 = urllib.parse.urlencode({'phoneVal': 联通手机号, 'type': 21}) 参数 = 参数.encode() urllib.request.urlopen('https://m.10010.com/god/AirCheckMessage/sendCaptcha', 参数) 短信验证码 = input('请输入收到的验证码:') 统一资源定位符 = 'https://m.10010.com/god/qingPiCard/flowExchange?number=%s&type=21&captcha=%s' % ( 联通手机号, 短信验证码) urllib.request.urlopen(统一资源定位符) def 运行次数(): 手机号 = input("输入一个联通手机号:") 验证联通手机号(手机号) 次数 = 3 间隔时间 = 60 for 循环 in range(次数): 短信验证(联通手机号=手机号) 循环次数 = 循环 + 1 print('第{}次运行结束.'.format(循环次数)) if 循环次数 != 3: print('%s秒后继续运行.' % 间隔时间) time.sleep(间隔时间) if __name__ == '__main__': 运行次数()

    用户交互界面 版(tkinter): https://blog.csdn.net/u012336596/article/details/112561338

    Processed: 0.013, SQL: 8