def loginin(self): """ 功能:登录托福网站 参数:None 返回:ok:登陆成功,error:登录失败 """ self.tuoful_session.cookies.clear() # self.tuoful_session.proxies = {'http':"120.77.35.48:8899"} # content = self.tuoful_session.get("http://httpbin.org/ip") # print(content.text) response = self.tuoful_session.get("http://toefl.etest.net.cn/cn/") text = response.content.decode("gb2312") if "登录" not in text: return "error" cook = response.cookies coo = {c.name: c.value for c in response.cookies} if "yunsuo_session_verify" in coo: return "error" else: temp_list = [] for key,value in coo.items(): srt = "%s=%s"%(key,value) temp_list.append(srt) self.Cookie_str = ";".join(temp_list) header_yz_login = headers_all(self.Cookie_str)["header_yz_login"] picUrl = "https://toefl.etest.net.cn/cn/"+ str(int(time.time()*1000))+str(random.random())[1:]+"VerifyCode3.jpg" content_pic = self.tuoful_session.get(picUrl,headers = header_yz_login) num = only_num() #获取验证码内容 codeContent = self.jpg2str(num, content_pic) headers_login = headers_all(self.Cookie_str)["headers_login"] s = str_md5("%s%s"%(self.neea_pwd, self.neea)) x = s+codeContent pwd = str_md5(x) payload = {"username":"******"%self.neea,"__act":"__id.24.TOEFLAPP.appadp.actLogin","password":pwd,"LoginCode":codeContent,"btn_submit.x":"0","btn_submit.y":"0"} v = self.tuoful_session.post("https://toefl.etest.net.cn/cn/TOEFLAPP",data=payload, headers=headers_login) text = v.content.decode("gb2312") if "0; URL=/cn/MyHome/?" in text: return "ok" elif "验证码错误" in text: now = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) print("%slogin验证码错误"%(now)) return "error" elif "密码不正确" in text: now = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) print("%s密码不正确或验证码获取有误"%(now)) return "error" else: print("发生未知错误 请查看login_error.txt文件") with open("login_error.txt", "w") as f: f.write(text) return "error"
def ktq(request): STRCONTEXT = { "MerchantNo": "201805021010006", "vcRobotSerialNo": "159562E24C83A1131D41E7887CB4FCC8", "nType": "10", "vcChatRoomSerialNo": "", "nCodeCount": "1", "nAddMinute": "10", "nIsNotify": "0", "vcNotifyContent": "" } STRSIGN = str_md5(str(STRCONTEXT) + "testdaily123456") content = requests.get( "http://skyagent.shequnguanjia.com/Merchant.asmx/ApplyCodeList?strContext=%s&strSign=%s" % (STRCONTEXT, STRSIGN)) res = content.text res = eval(res) res = res["Data"] res = res[0] res = res["ApplyCodeData"] res = res[0] res = res["vcCode"] template = loader.get_template('kaoweitongapp/yz.html') context = template.render({"yz": res}) return HttpResponse(context)
def send_weixin(vcChatRoomSerialNo): # 发送群回调 STRCONTEXT = { "MerchantNo": "201805021010006", "vcChatRoomSerialNo": "%s" % vcChatRoomSerialNo } STRSIGN = str_md5(str(STRCONTEXT) + "testdaily123456") content = requests.get( "http://skyagent.shequnguanjia.com/Merchant.asmx/ChatRoomUserInfo?strContext=%s&strSign=%s" % (STRCONTEXT, STRSIGN))
def kicking(request): if request.method == "POST": vcChatRoomSerialNo = request.POST.get("vcChatRoomSerialNo") vcSerialNo = request.POST.get("vcSerialNo") STRCONTEXT = { "MerchantNo": "201805021010006", "Data": [{ "vcRelationSerialNo": "000000000002", "vcChatRoomSerialNo": "%s" % vcChatRoomSerialNo, "vcWxUserSerialNo": "%s" % vcSerialNo, "vcComment": "" }] } STRSIGN = str_md5(str(STRCONTEXT) + "testdaily123456") content = requests.get( "http://skyagent.shequnguanjia.com/Merchant.asmx/ChatRoomKicking?strContext=%s&strSign=%s" % (STRCONTEXT, STRSIGN)) return HttpResponse(content.text)
def robotmass(request): # 机器人发送群消息 if request.method == "POST": msgtype = request.POST.get("msgtype") vcTitle = request.POST.get("vcTitle") vcDesc = request.POST.get("vcDesc") vcHref = request.POST.get("vcHref") nIsHit = request.POST.get("nIsHit") if not vcTitle: vcTitle = "" vcDesc = "" vcHref = "" if msgtype == "text": msgtype = "2001" elif msgtype == "href": msgtype = "2005" group = request.POST.get("group") content = request.POST.get("content") vcRelaSerialNo = random_num() # 随机流水号 if group == "数学": print(content) for vcChatRoomSerialNo in vcChatRoomSerialNo_math: STRCONTEXT = join_get(vcRelaSerialNo, content, vcChatRoomSerialNo, msgtype, vcTitle, vcDesc, vcHref, nIsHit) STRSIGN = str_md5(json.dumps(STRCONTEXT) + "testdaily123456") d = {"STRCONTEXT": json.dumps(STRCONTEXT), "STRSIGN": STRSIGN} res = requests.post( "http://skyagent.shequnguanjia.com/Merchant.asmx/MerchantSendMessages", data=d) return HttpResponse("ok") elif group == "1": # SAT for vcChatRoomSerialNo in vcChatRoomSerialNo_2018SAT: STRCONTEXT = join_get(vcRelaSerialNo, content, vcChatRoomSerialNo, msgtype, vcTitle, vcDesc, vcHref, nIsHit) STRSIGN = str_md5(json.dumps(STRCONTEXT) + "testdaily123456") d = {"STRCONTEXT": json.dumps(STRCONTEXT), "STRSIGN": STRSIGN} res = requests.post( "http://skyagent.shequnguanjia.com/Merchant.asmx/MerchantSendMessages", data=d) return HttpResponse("ok") elif group == "2": # SAT2 for vcChatRoomSerialNo in vcChatRoomSerialNo_2018SAT2: STRCONTEXT = join_get(vcRelaSerialNo, content, vcChatRoomSerialNo, msgtype, vcTitle, vcDesc, vcHref, nIsHit) STRSIGN = str_md5(json.dumps(STRCONTEXT) + "testdaily123456") d = {"STRCONTEXT": json.dumps(STRCONTEXT), "STRSIGN": STRSIGN} res = requests.post( "http://skyagent.shequnguanjia.com/Merchant.asmx/MerchantSendMessages", data=d) return HttpResponse("ok") elif group == "托福付费": for vcChatRoomSerialNo in vcChatRoomSerialNo_tuofufufei: STRCONTEXT = join_get(vcRelaSerialNo, content, vcChatRoomSerialNo, msgtype, vcTitle, vcDesc, vcHref, nIsHit) STRSIGN = str_md5(json.dumps(STRCONTEXT) + "testdaily123456") d = {"STRCONTEXT": json.dumps(STRCONTEXT), "STRSIGN": STRSIGN} res = requests.post( "http://skyagent.shequnguanjia.com/Merchant.asmx/MerchantSendMessages", data=d) return HttpResponse("ok") elif group == "大漠点词": for vcChatRoomSerialNo in vcChatRoomSerialNo_damodianci: STRCONTEXT = join_get(vcRelaSerialNo, content, vcChatRoomSerialNo, msgtype, vcTitle, vcDesc, vcHref, nIsHit) STRSIGN = str_md5(json.dumps(STRCONTEXT) + "testdaily123456") d = {"STRCONTEXT": json.dumps(STRCONTEXT), "STRSIGN": STRSIGN} res = requests.post( "http://skyagent.shequnguanjia.com/Merchant.asmx/MerchantSendMessages", data=d) return HttpResponse("ok") elif group == "3": # SAT对赌 for vcChatRoomSerialNo in vcChatRoomSerialNo_SATduidu: STRCONTEXT = join_get(vcRelaSerialNo, content, vcChatRoomSerialNo, msgtype, vcTitle, vcDesc, vcHref, nIsHit) STRSIGN = str_md5(json.dumps(STRCONTEXT) + "testdaily123456") d = {"STRCONTEXT": json.dumps(STRCONTEXT), "STRSIGN": STRSIGN} res = requests.post( "http://skyagent.shequnguanjia.com/Merchant.asmx/MerchantSendMessages", data=d) return HttpResponse("ok") elif group == "AP": # AP for vcChatRoomSerialNo in vcChatRoomSerialNo_AP: STRCONTEXT = join_get(vcRelaSerialNo, content, vcChatRoomSerialNo, msgtype, vcTitle, vcDesc, vcHref, nIsHit) STRSIGN = str_md5(json.dumps(STRCONTEXT) + "testdaily123456") d = {"STRCONTEXT": json.dumps(STRCONTEXT), "STRSIGN": STRSIGN} res = requests.post( "http://skyagent.shequnguanjia.com/Merchant.asmx/MerchantSendMessages", data=d) return HttpResponse("ok")