def getWinList(): api = HOST + 'profile/win' data = '{ "PageNo": 1}' response = post(api, headers=getHeaders(), data=data, verify=False) winList = response["LotteryWinRecordList"] if not winList is None: if len(winList) == 0: Logger.v('今日头条全民抽奖还没有中过奖') return else: noAdressList = list( filter(lambda winItem: winItem['UserName'] == None, winList)) or [] if len(noAdressList) == 0: Logger.v('今日头条全民抽奖没有未填写地址的中奖项') return else: Logger.v('今日头条全民抽奖发现{}个未填写地址的中奖项'.format(len(noAdressList))) result = [] for item in noAdressList: time.sleep(3) winRecordNo = item['WinRecordNo'] name = item['LotteryPrize']['Name'] des = item['LotteryPrize']['Desc'] result.append('新中奖项:' + name + '(' + des + '),填写地址' + ( '成功' if _configAdress(winRecordNo) else '失败')) noticeTxt = '今日头条全民抽奖中奖啦:\n' + ';\n'.join(result) + '。' Logger.v(noticeTxt) import notice.noticeManager notice.noticeManager.sendNoticeAnyway('恭喜!' + noticeTxt) else: Logger.e('今日头条全民抽奖获取中奖列表失败:', response['Msg'])
def autoCollectCoins(): # 1、请求首页数据,检查是否有coin可以收集。有则将coin保存到列表容器 response = post('https://star.8.163.com/api/home/index', headers=headers, cookies=getCookies(), verify=False) if response['data'] is None: Logger.e('网易星球收取黑钻失败', response['msg']) if '登录失败' in response['msg']: Logger.n('网易星球登录失败', '可能为session过期') global retryTimes if retryTimes < 1: retryTimes += 1 updateCookie() autoCollectCoins() else: retryTimes = 0 return collectCoinsList = response['data']['collectCoins'] if len(collectCoinsList) == 0: Logger.v('网易星球当前没有黑钻可收取') else: # 2、检查coin列表容器是否有值,遍历请求领取coin接口 Logger.v('共有{}个黑钻可收取'.format(len(collectCoinsList))) count = 0.0 for collectCoinsItem in collectCoinsList: if collectCoins(collectCoinsItem['id']): count += float(collectCoinsItem['virCount']) Logger.v('网易星球收取黑钻完毕,本次收取{}颗黑钻'.format(count))
def sendMsg(msgJson): accessToken = Tocken().get_access_token() postUrl = ("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=%s" % accessToken ) result = post(postUrl,json=msgJson) if result['errcode']: Logger.e('发送微信消息失败',result['errmsg']) return False return True
def collectVigor(id): time.sleep(1) api = HOST + '/data/vigor/get' timestamp = time.time() * 1000 data = '{"amount":%s,"requestId":%d,"appId":1,"tpl":"","timeStamp":null,"nounce":null,"token":null,"phoneType":"android"}' % ( id, timestamp) response = post(api, headers=getHeader(timestamp), data=data, verify=False) count = float(response['data']['amount']) return count
def upload(filePath, mediaType): accessToken = Tocken().get_access_token() file = {'file': open(filePath, 'rb')} param = {'media': file} postUrl = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=%s&type=%s" % ( accessToken, mediaType) result = post(postUrl, files=file) # print('upload:', filePath, result) return result
def lottery(): time.sleep(2) api = HOST + '/data/lottery/draw' timestamp = time.time() * 1000 data = '{"requestId":%d,"appId":1,"tpl":"","timeStamp":null,"nounce":null,"token":null,"phoneType":"android"}' % timestamp response = post(api, headers=getHeader(timestamp), data=data, verify=False) errorMsg = response['errorMsg'] if errorMsg == 'success': Logger.v('百度莱茨狗抽奖成功') else: Logger.e('百度莱茨狗抽奖失败', errorMsg)
def joinLotery(productId): api = HOST + productId + '/join' data = '{"form_id":"subscribe_message","subscribe_message":["join_lottery"]}' response = post(api, headers=getHeaders(), data=data, verify=False) result = response.get('result') if result is None: Logger.e('微信抽奖助手抽奖' + productId + '失败', response.get('error', {}).get('message')) return False else: return result
def _configAdress(no): api = HOST + 'address' ADRESS_INFO['WinRecordNo'] = no ADRESS_INFO['JoinUid'] = UID data = json.dumps(ADRESS_INFO) response = post(api, headers=getHeaders(), data=data, verify=False) if response['Status'] == 0: return True else: Logger.e('今日头条全民抽奖填写地址:' + no + '失败:', response['Msg']) return False
def joinLotery(productId): api = HOST + 'lotteries/' + productId + '/join' data = '{"template": "lGOfpVZAzg5VaoX761nwQAmtQ94-UssmZ4ARrnUXegY"}' response = post(api, headers=getHeaders(), data=data, verify=False) result = response.get('success', False) if result: return result else: Logger.e('微信活动抽奖抽奖' + productId + '失败', response.get('message', {}).get('error')) return False
def collectAllVigor(): time.sleep(1) api = HOST + '/data/vigor/getall' timestamp = time.time() * 1000 data = '{"requestId":%d,"appId":1,"tpl":"","timeStamp":null,"nounce":null,"token":null,"phoneType":"android"}' % timestamp response = post(api, headers=getHeader(timestamp), data=data, verify=False) amounts = response['data']['amounts'] if len(amounts) > 0: count = 0.0 for amount in amounts: count += float(amount) Logger.v('百度莱茨狗一键收取元气完毕,本次收取{}个元气'.format(count))
def joinLotery(productId): api = HOST + 'v4/join' global TOKEN data = '{"lid": "' + productId + '","access_token":"' + TOKEN + '","join": 1,"join_token": "","more": 1}' # data ={"lid": productId,"access_token":TOKEN,"join": 1,"join_token": "","more": 1} response = post(api, headers=getHeaders(), data=data, verify=False) result = response.get('msg', 'error') if result == '': return True else: Logger.e('微信抽奖工具抽奖' + productId + '失败', result) return False
def joinLotery(no): time.sleep(3) api = HOST + 'join' data = '{ "ActivityNo": "%s", "JoinUid": %d, "SystemInfo": %s}' % ( no, UID, json.dumps(SYS_INFO)) response = post(api, headers=getHeaders(), data=data, verify=False) if response['Status'] == 0: return 1 elif response['Status'] == 101: return 3 else: Logger.e('今日头条全民抽奖失败', response['Msg'] or response['message']) return 2
def getVigorList(): api = HOST + '/data/vigor/generate' timestamp = time.time() * 1000 data = '{"requestId":%d,"appId":1,"tpl":"","timeStamp":null,"nounce":null,"token":null,"phoneType":"android"}' % timestamp response = post(api, headers=getHeader(timestamp), data=data, verify=False) if response['errorNo'] != '00': Logger.n('百度莱茨狗收取元气失败', '错误代码' + response['errorNo']) return vigorList = response['data']['amounts'] if len(vigorList) == 0: Logger.v('百度莱茨狗当前没有元气可收取') else: Logger.v('共有{}个元气可收取'.format(len(vigorList))) # count = 0.0 # for vigor in vigorList: # count += collectVigor(vigor) # Logger.v('百度莱茨狗收取元气完毕,本次收取{}个元气'.format(count)) collectAllVigor()
def updateCookie(): Logger.v('尝试自动更新网易星球cookie') data = '{"p":"WObwO2HPjFkkaaEjWgRG1EHmrIP/SOaQT+GMoThH609UM47CRGDYhD4YKQ5p6Gy4PvmcJwPszmWv8S/NerKjNI7ELqmlu5IlnxqGhyPjIHxe6LVMKe4EbJD2da8vRaR/E9Wrxqvrto6qCZsDDjWoH4Ul7Uqg/YP9gCmFJE2lnYmqNxLaRZ4s6i7m3EEt8Ew2vIc85P3XGVTT3hwV4ZMNylket04jcCCEXWJM5zZMJL2Y9Jg+TFu71C0vFMDu637L2ruD2zALKxs4tGdHC9EtT3e5Miwq+0GaJd+v0xL5bGInKW8QOSrQzrQOENeYRO7NF80xtlLu9bmyYtqpr6wS835BUxrn3hn6MV4EtR6NNNI\u003d","k":"Zoqzg9mEAOr3bo6N/Qp5T8+mBUZB5mv7iUzon1J0VcyvWAmCVWOh3/x6FCHNo/qIjV5qlTFnWJL7Fw8zynmevfGTdsIGmzrAD8QAQ5SySNJHujWvpQo51eEk4d5EyI/WWaGrUqx2VzswCQikqEER/UcG4Qo8A053HP8zHkVYu70\u003d"}' headers = { 'user-agent': 'Mozilla/5.0 (Linux; Android 8.1.0; Mi Note 3 Build/OPM1.171019.019; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.112 Mobile Safari/537.36', 'appmeta': 'eyJhcHBWZXJzaW9uIjoiMS45LjYiLCJPUyI6IkFuZHJvaWRfMjkiLCJhcHBOYW1lIjoi5pif55CDIiwiY2hhbm5lbCI6ImUwMTE3MDAwNCIsImFudGlTcGFtSW5mbyI6IntcImRhdGF0eXBlXCI6XCJhaW10X2RhdGFzXCIsXCJpZF92ZXJcIjpcIkFuZHJvaWRfMS4wLjFcIixcInJkYXRhXCI6XCJqSkRHLzhFNmtWb0lZRjJ0UXJCajdBVHlHaFEvYVhON3RtdU9mUW16ek5SeUdyT2JPQVBLU0lwZUFpdFQwbXFaYURxcWtKck5GSmtmQmpaY3ZwZklGSjlmV1NaYThnVVBvaWhhZzVtSndTVXBvTkEwZWtqT0EwbVRKSEw0ZFZ2enBUd0RZT0FjU05oNThHWG9NaFVw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', 'accept-encoding': 'gzip' } response = post('https://star.8.163.com/api/starUser/getCookie', data=data, headers=headers, verify=False) newCookie = response['data']['cookie'] if not newCookie is None: global cookie cookie = newCookie Logger.v('已自动更新网易星球cookie:' + cookie)
def getJson(url, page, lang_name): '''返回当前页面的信息列表''' headers = { 'Host': 'www.lagou.com', 'Connection': 'keep-alive', 'Content-Length': '23', 'Origin': 'https://www.lagou.com', 'X-Anit-Forge-Code': '0', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'X-Requested-With': 'XMLHttpRequest', 'X-Anit-Forge-Token': 'None', 'Referer': 'https://www.lagou.com/jobs/list_python?city=%E5%85%A8%E5%9B%BD&cl=false&fromSearch=true&labelWords=&suginput=', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7' } data = {'first': 'false', 'pn': page, 'kd': lang_name} json = post(url, data, headers=headers) list_con = json['content']['positionResult']['result'] info_list = [] for i in list_con: info = [] info.append(i.get('companyShortName', '无')) info.append(i.get('companyFullName', '无')) info.append(i.get('industryField', '无')) info.append(i.get('companySize', '无')) info.append(i.get('salary', '无')) info.append(i.get('city', '无')) info.append(i.get('education', '无')) info.append(i.get('workYear', '无')) info.append(i.get('positionName', '无')) info.append(i.get('createTime', '无')) info.append(i.get('positionAdvantage', '无')) info_list.append(info) return info_list
def collectCoins(coinId): headers = { 'Host': 'star.8.163.com', 'Accept': 'application/json, text/plain, */*', 'X-Requested-With': 'XMLHttpRequest', 'Accept-Language': 'zh-cn', 'Cache-Control': 'max-age=0', 'Content-Type': 'application/json;charset=UTF-8', 'Origin': 'https://star.8.163.com', 'User-Agent': 'Mozilla/5.0 (Linux; Android 8.1.0; Mi Note 3 Build/OPM1.171019.019; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/68.0.3440.91 Mobile Safari/537.36 hybrid/1.0.0 star_client_info_begin {hybridVersion: "1.0.0",clientVersion: "1.9.0",accountId: "024ed4d78de15bc2cf623972b6dc77d26a752f5977eadbbcb91c9a4bff23c604",channel: "e01170023"}star_client_info_end', 'Referer': 'https://star.8.163.com/m', } data = '{"id":%s}' % coinId response = post('https://star.8.163.com/api/starUserCoin/collectUserCoin', headers=headers, cookies=getCookies(), data=data, verify=False) result = response['msg'] if not '成功' in result: Logger.e('网易星球收取黑钻失败', result) return False return True
def create(self, postData, accessToken): postUrl = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=%s" % accessToken if isinstance(postData, str): postData = postData.encode('utf-8') result = post(postUrl, postData) print('create:', result)