【Python】任推邦近30日推广数据采集+推送

不知道任推邦是啥的,可以查看之前的文章:夸克网盘扩容N次20T的方法 

本文主要是针对夸克网盘的,其他项目有的没有提供接口,如果有也自行抓包,参考修改一下就行了。主要是将接口返回内容以html表格形式进行推送,可以极其清晰的看出你的数据有多惨淡哈哈。

采集范围:近30条

效果图:

4a22d80628ad016fb8244cbc6982386e.png

刚好最近切换推送平台,也当做演示如何写推送代码吧。

以下是PushPlus推送的完整代码:

import requests,json,time


push_token = '' #pushplus的token
push_title = '任推邦' #推送标题
push_content = '偶尔敲代码' #推送内容
tgm = '100XXXXXXXXX'#夸克网盘推广码,其余的接口不一样


def pushplus_send():
    data = {
        "token": push_token,
        "title": push_title,
        "content": push_content,
        "template": "html"}
    body = json.dumps(data).encode(encoding='utf-8')
    response = requests.post('http://www.pushplus.plus/send', data=body)
    print(response.text)


url = "https://dt.bd.cn/main/quark_list"
headers = {
        "Host": "dt.bd.cn",
        "Connection": "keep-alive",
        "Content-Length": "15",
        "Accept": "*/*",
        "X-Requested-With": "XMLHttpRequest",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x6309092b) XWEB/9105 Flue",
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        "Origin": "https://dt.bd.cn",
        "Sec-Fetch-Site": "same-origin",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Dest": "empty",
        "Referer": "https://dt.bd.cn/main/quark_list",
        "Accept-Encoding": "gzip, deflate, br",
        "Accept-Language": "zh-CN,zh;q=0.9"}
body = f'bs={tgm}'
response = requests.post(url=url, data=body, headers=headers)
#print(response.text)
try:
        aaa = json.loads(response.text)
        if aaa['msg'] == 'ok' :
            print(f'获取成功')
            i = 0
            html_code = "<table>\n<tr>\n<th>日期</th>\n<th>手机拉新 </th>\n<th>PC拉新 </th>\n<th>转存数 </th>\n<th>会员分成 </th>\n</tr>\n"
            for list in aaa['data']['list']:
                #print(list['date_str'],list['mobile_count'],list['pc_count'],list['store_count'],list['mobile_fencheng'])
                html_code += "<tr>\n"
                html_code += f"<td style='border: 1px solid black;'>{list['date_str']}   </td>\n"
                html_code += f"<td style='border: 1px solid black;'>{list['mobile_count']}</td>\n"
                html_code += f"<td style='border: 1px solid black;'>{list['pc_count']}</td>\n"
                html_code += f"<td style='border: 1px solid black;'>{list['store_count']}</td>\n"
                html_code += f"<td style='border: 1px solid black;'>{list['mobile_fencheng']}</td>\n"
                html_code += "</tr>\n"


                i = i + 1
                if i >30 :# 取30条 {"code":999,"msg":"发送内容过大,不能超过2万字","data":null}
                    break


            html_code += "</table>"
            push_content=html_code
            pushplus_send()
        else:
            print(f'获取失败')
except Exception:
        print(response.text)

以下是WxPusher推送的完整代码:

import requests,json,time


push_token = 'UID_RXXXXX' #wxpusher的UID
push_title = '任推邦' #推送标题
push_content = '偶尔敲代码' #推送内容
tgm = '1000XXXXXX'#夸克网盘推广码,其余的接口不一样
wxapp_token = 'AT_XXXXXX' #wxpusher的APPTOKEN


def wxpusher_send():
    headers = {'Content-Type': 'application/json;charset=utf-8'}
    data = {
            "appToken": wxapp_token,
            "uids": [f"{push_token}"],
            "topicIds": [],
            "summary": push_title,
            "content": push_content,
            "contentType": 2,
            "verifyPay": False
        }
    json_data = json.dumps(data)
    response = requests.post('https://wxpusher.zjiecode.com/api/send/message', headers=headers, data=json_data)
    print(response.text)


url = "https://dt.bd.cn/main/quark_list"
headers = {
        "Host": "dt.bd.cn",
        "Connection": "keep-alive",
        "Content-Length": "15",
        "Accept": "*/*",
        "X-Requested-With": "XMLHttpRequest",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x6309092b) XWEB/9105 Flue",
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        "Origin": "https://dt.bd.cn",
        "Sec-Fetch-Site": "same-origin",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Dest": "empty",
        "Referer": "https://dt.bd.cn/main/quark_list",
        "Accept-Encoding": "gzip, deflate, br",
        "Accept-Language": "zh-CN,zh;q=0.9"}
body = f'bs={tgm}'
response = requests.post(url=url, data=body, headers=headers)
#print(response.text)
try:
        aaa = json.loads(response.text)
        if aaa['msg'] == 'ok' :
            print(f'获取成功')
            i = 0
            html_code = "<table>\n<tr>\n<th>日期</th>\n<th>手机拉新 </th>\n<th>PC拉新 </th>\n<th>转存数 </th>\n<th>会员分成 </th>\n</tr>\n"
            for list in aaa['data']['list']:
                #print(list['date_str'],list['mobile_count'],list['pc_count'],list['store_count'],list['mobile_fencheng'])
                html_code += "<tr>\n"
                html_code += f"<td style='border: 1px solid black;'>{list['date_str']}   </td>\n"
                html_code += f"<td style='border: 1px solid black;'>{list['mobile_count']}</td>\n"
                html_code += f"<td style='border: 1px solid black;'>{list['pc_count']}</td>\n"
                html_code += f"<td style='border: 1px solid black;'>{list['store_count']}</td>\n"
                html_code += f"<td style='border: 1px solid black;'>{list['mobile_fencheng']}</td>\n"
                html_code += "</tr>\n"


                i = i + 1
                if i >30 :# 取30条 {"code":999,"msg":"发送内容过大,不能超过2万字","data":null}
                    break


            html_code += "</table>"
            #print(html_code)
            push_content=html_code
            wxpusher_send()
        else:
            print(f'获取失败')
except Exception:
        print(response.text)

都看到这了,我插个广告:推文第二条是好评100%的推广工具~

- End -

更多精彩文章

点击下方名片关注【偶尔敲代码】

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值