panchengyong
2024-11-24 fc8d6fed1e4485dd1a84eb38874f878bb7a0bb35
获取登录信息更新
3 files modified
1 files added
94 ■■■■■ changed files
database/model.py 2 ●●●●● patch | view | raw | blame | history
login.py 36 ●●●● patch | view | raw | blame | history
wxpush-qid-parse.py 42 ●●●●● patch | view | raw | blame | history
wxpush-url-parse.py 14 ●●●● patch | view | raw | blame | history
database/model.py
@@ -46,6 +46,7 @@
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键,自增ID')
    device_name = Column(String(255), nullable=True, comment='设备别名')
    income = Column(String(255), nullable=True, comment='今日收益')
    income_detail_html =  Column(Text, nullable=True, comment='今日收益明细')
    date = Column(String(255), nullable=True, comment='日期')
    date_time = Column(String(255), nullable=True, comment='收益时间')
    create_time = Column(DateTime, default=func.now(), nullable=True, comment='创建时间')
@@ -56,6 +57,7 @@
            'id': self.id,
            'device_name': self.device_name,
            'income': self.income,
            'income_detail_html': self.income_detail_html,
            'date': self.date,
            'date_time': self.date_time,
            'update_time': self.update_time,
login.py
@@ -28,9 +28,9 @@
            while True:
                cookie_dict = cookies_to_dict(page.cookies())
                if cookie_dict.get('publish_badge_show_info', None):
                    if nickname := page.ele('xpath://*[@id="douyin-right-container"]/div[2]/div/div/div[2]/div[2]/div[1]/h1/span/span/span/span/span/span'):
                    if nickname := page.ele('xpath://*[@id="douyin-right-container"]/div[2]/div/div/div/div[2]/div[2]/div[1]/h1/span/span/span/span/span/span'):
                        nickname = nickname.text
                    if unique_no := page.ele('xpath://*[@id="douyin-right-container"]/div[2]/div/div/div[2]/div[2]/p/span[1]'):
                    if unique_no := page.ele('xpath://*[@id="douyin-right-container"]/div[2]/div/div/div/div[2]/div[2]/p/span[1]'):
                        unique_no = unique_no.text
                    cookie = Cookie(
                        nickname=nickname if nickname else None,
@@ -41,12 +41,8 @@
                        cookie=json.dumps(cookie_dict),
                        user_agent=user_agent,
                        is_valid=True,
                    #     在此更改租户
<<<<<<< HEAD
                        tenant_id=47,
=======
                        #在此更改租户
                        tenant_id=tenant_id,
                    )
                    add_cookie(cookie)
                    page.close()
@@ -84,10 +80,8 @@
                        cookie=json.dumps(cookie_dict),
                        user_agent=user_agent,
                        is_valid=True,
                        #     在此更改租户
                        #在此更改租户
                        tenant_id=tenant_id,
>>>>>>> d79472d6baae4d507124da71a5c38fc17fbb8bd4
                    )
                    add_cookie(cookie)
                    page.close()
@@ -136,7 +130,7 @@
                        cookie=json.dumps(cookie_dict),
                        user_agent=user_agent,
                        is_valid=True,
                    #     在此更改租户
                        # 在此更改租户
                        tenant_id=tenant_id
                    )
                    add_cookie(cookie)
@@ -172,34 +166,22 @@
if __name__ == '__main__':
    thread_dy = threading.Thread(target=login_dy)
<<<<<<< HEAD
    # thread_ks = threading.Thread(target=login_ks)
=======
    thread_ks = threading.Thread(target=login_ks)
    thread_xhs= threading.Thread(target=login_xhs)
>>>>>>> d79472d6baae4d507124da71a5c38fc17fbb8bd4
    # thread_xhs= threading.Thread(target=login_xhs)
    # thread_dy2 = threading.Thread(target=login_dy)
    # thread_ks2 = threading.Thread(target=login_ks)
    # 启动线程
    thread_dy.start()
<<<<<<< HEAD
    # thread_ks.start()
=======
    thread_ks.start()
    thread_xhs.start()
>>>>>>> d79472d6baae4d507124da71a5c38fc17fbb8bd4
    # thread_xhs.start()
    # thread_dy2.start()
    # thread_ks2.start()
    # 等待线程完成
    thread_dy.join()
<<<<<<< HEAD
    # thread_dy.join()
    # thread_ks.join()
=======
    thread_ks.join()
    thread_xhs.join()
>>>>>>> d79472d6baae4d507124da71a5c38fc17fbb8bd4
    # thread_xhs.join()
    # thread_dy2.join()
    # thread_ks2.join()
#
wxpush-qid-parse.py
New file
@@ -0,0 +1,42 @@
from bs4 import BeautifulSoup
from urllib.request import urlopen
import requests
import json
import time
from datetime import datetime, timezone, timedelta
from database.crud.profit_crud import add_profit
from database.model import Profit
from loguru import logger
def wxpusher_qid_get():
    try:
        qid_url = 'https://wxpusher.zjiecode.com/api/message/kRxb8wm6nGpMMhj3SmBfPmRVcNUUpmXI'
        html = urlopen(qid_url)
        bs = BeautifulSoup(html.read(), 'html.parser')
        print(bs.table)
    except Exception as e:
        print(e)
def timestamp_to_beijing_time(timestamp):
    # 将时间戳转换为UTC时间
    utc_time = datetime.fromtimestamp(timestamp, tz=timezone.utc)
    # 将UTC时间转换为北京时间
    beijing_time = utc_time.astimezone(timezone(timedelta(hours=8)))
    return beijing_time
def get_proxy():
    url = 'https://dps.kdlapi.com/api/getdps/?secret_id=ow29gv0wr0nr5yvcbtn5&signature=0k1raqnz76c66es1aqlxv43ft95djlkd&num=1&pt=1&sep=1'
    response = requests.get(url=url)
    username = 'd2858801809'
    password = 'd510hlqd'
    proxies = {
        'http': f'http://{username}:{password}@{response.text.strip()}',
        'https': f'http://{username}:{password}@{response.text.strip()}'
    }
    print(f'使用{response.text}进行代理')
    return response.text
if __name__ == '__main__':
    wxpusher_qid_get()
wxpush-url-parse.py
@@ -1,4 +1,5 @@
from bs4 import BeautifulSoup
from urllib.request import urlopen
import requests
import json
import time
@@ -12,7 +13,8 @@
    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/1162099064'
        url_api = 'https://wxpusher.zjiecode.com/api/wxuser/orPQ805lifWDllPc5xVXiFykV4i8/message/922337203685477600'
        #
        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'
        }
@@ -60,15 +62,23 @@
                print("date:", date)
                create_time = time.strftime("%Y-%m-%d %H:%M:%S", localTime)
                print("createTime:", create_time)
                qid_url = 'https://wxpusher.zjiecode.com/api/message/'+item["qid"]
                html = urlopen(qid_url)
                bs = BeautifulSoup(html.read(), 'html.parser')
                income_detail_table =bs.table
                print("income_detail_table:", income_detail_table)
                #写入数据库
                profit = Profit(
                    device_name= summary_device_name if summary_device_name else None,
                    income = summary_income if summary_income else None,
                    income_detail_html = income_detail_table if income_detail_table 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)
                add_profit(profit)
                #调用流量牛api同步数据
                headers4lln = {
                    "Accept": "*/*",