panchengyong
2024-09-30 a7e655a9cd1c325d5238e7cfcb3d9259452915a7
设备收益分析修改
1 files modified
111 ■■■■■ changed files
wxpush-url-parse.py 111 ●●●●● patch | view | raw | blame | history
wxpush-url-parse.py
@@ -11,7 +11,8 @@
def wxpusher_get():
    try:
        url = 'https://wxpusher.zjiecode.com/wxuser/?openId=orPQ805lifWDllPc5xVXiFykV4i8#/history-message'
        url_api = 'https://wxpusher.zjiecode.com/api/wxuser/orPQ805lifWDllPc5xVXiFykV4i8/message/922337203685477600'
        # url_api = 'https://wxpusher.zjiecode.com/api/wxuser/orPQ805lifWDllPc5xVXiFykV4i8/message/922337203685477600'
        url_api = 'https://wxpusher.zjiecode.com/api/wxuser/orPQ805lifWDllPc5xVXiFykV4i8/message/1162099064'
        headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'
        }
@@ -25,53 +26,69 @@
        print("======response result data=======")
        print(len(data))
        for item in data:
            summary = item["summary"]
            summary_index_1 = summary.index('\n')
            summary_content = summary[0:summary_index_1]
            print("summary:", summary_content)
            summary_content_1 = summary_content.index('--')
            summary_device_name = summary[0:summary_content_1]
            summary_income = summary[summary_content_1+2:summary_index_1-1]
            print("summary_device_name:", summary_device_name)
            print("summary_income:", summary_income)
            print("createTime:", item["createTime"])
            try:
                summary = item["summary"]
                uid_name = item["name"]
                print(uid_name)
                if uid_name == '赚米收益推送':
                    print("summary原内容", summary.replace("\n", ""))
                    summary_index_1 = summary.index('元')
                    summary_content = summary[0:summary_index_1]
                    print("summary:", summary_content)
                    summary_content_1 = summary_content.index('--')
                    summary_device_name = summary[0:summary_content_1]
                    summary_income = summary[summary_content_1 + 2:summary_index_1]
                else:
                    # uid_name == '阿拉丁每天收益推送‘
                    summary_content = summary
                    summary_content_2 = summary_content.index('+')
                    summary_device_name = summary[0:summary_content_2]
                    summary_income = summary[summary_content_2 + 1]
            timeStamp = item["createTime"]
            # 修正时间戳
            str_timestamp = str(timeStamp)
            new_tiemstamp = str_timestamp[0:len(str_timestamp)-3]
            print("new_tiemstamp:", new_tiemstamp)
            localTime = time.localtime(int(new_tiemstamp))
            # print("beijing_time:", timestamp_to_beijing_time(new_tiemstamp))
            date = time.strftime("%Y-%m-%d", localTime)
            print("date:", date)
            create_time = time.strftime("%Y-%m-%d %H:%M:%S", localTime)
            print("createTime:", create_time)
            #写入数据库
            profit = Profit(
                device_name= summary_device_name if summary_device_name else None,
                income = summary_income if summary_income else None,
                date = date if date else None,
                date_time = create_time if create_time else None,
                # date_time= create_time if create_time else None
            )
            #add_profit(profit)
            #调用流量牛api同步数据
            headers4lln = {
                "Accept": "*/*",
                "Accept-Encoding": "gzip, deflate, br",
                "Accept-Language": "zh-CN,zh;q=0.9",
                "Connection": "keep-alive",
                "Content-Type": "application/json",
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
                              "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
            }
            add_profit_api = 'https://www.my1618.com.cn/api2/tests/insertIncome'
            params_value =  {"deviceProfitLogs": [ {'deviceName': summary_device_name, 'income': summary_income, 'date': date, 'dateTime': create_time} ] }
            resp_add_profit_api = requests.post(add_profit_api, json=params_value, headers=headers4lln)
            resp_text_add_profit_api = resp_add_profit_api.text
            print("======https://www.my1618.com.cn/api2/tests/insertIncome response result=======")
            print(resp_text_add_profit_api)
                print("summary_device_name:", summary_device_name)
                print("summary_income:", summary_income)
                # print("createTime:", item["createTime"])
                timeStamp = item["createTime"]
                # 修正时间戳
                str_timestamp = str(timeStamp)
                new_tiemstamp = str_timestamp[0:len(str_timestamp)-3]
                # print("new_tiemstamp:", new_tiemstamp)
                localTime = time.localtime(int(new_tiemstamp))
                # print("beijing_time:", timestamp_to_beijing_time(new_tiemstamp))
                date = time.strftime("%Y-%m-%d", localTime)
                print("date:", date)
                create_time = time.strftime("%Y-%m-%d %H:%M:%S", localTime)
                print("createTime:", create_time)
                #写入数据库
                profit = Profit(
                    device_name= summary_device_name if summary_device_name else None,
                    income = summary_income if summary_income else None,
                    date = date if date else None,
                    date_time = create_time if create_time else None,
                    # date_time= create_time if create_time else None
                )
                #add_profit(profit)
                #调用流量牛api同步数据
                headers4lln = {
                    "Accept": "*/*",
                    "Accept-Encoding": "gzip, deflate, br",
                    "Accept-Language": "zh-CN,zh;q=0.9",
                    "Connection": "keep-alive",
                    "Content-Type": "application/json",
                    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
                                  "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
                }
                add_profit_api = 'https://www.my1618.com.cn/api/tests/insertIncome'
                params_value =  {"deviceProfitLogs": [ {'deviceName': summary_device_name, 'income': summary_income, 'date': date, 'dateTime': create_time} ] }
                #resp_add_profit_api = requests.post(add_profit_api, json=params_value, headers=headers4lln)
                #resp_text_add_profit_api = resp_add_profit_api.text
                # print("======https://www.my1618.com.cn/api/tests/insertIncome response result=======")
                # print(resp_text_add_profit_api)
                print("\n")
            except Exception as fore:
                print("==========  Exception ============")
                print(fore)
    except Exception as e:
        print(e)