闲鱼助手——监控解析

import requests from bs4 import BeautifulSoup from selenium import webdriver from apscheduler.schedulers.blocking import BlockingScheduler # 配置Chrome驱动路径 chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless')  # 无头模式 driver = webdriver.Chrome(chrome_options=chrome_options) # 闲鱼的监控逻辑 def check_xianyu():    # 假设我们要监控的闲鱼商品页面的URL    url = 'https://item.taobao.com/item.htm?id=1234567890'    driver.get(url)    html = driver.page_source        # 使用BeautifulSoup解析HTML    soup = BeautifulSoup(html, 'html.parser')        # 假设我们要监控的是商品的价格,这里需要根据实际页面结构调整    price_element = soup.find('span', class_='J_Price')    if price_element:        current_price = price_element.text        # 假设我们有一个存储上次价格的变量        if not hasattr(check_xianyu, 'last_price'):            setattr(check_xianyu, 'last_price', current_price)        elif current_price != getattr(check_xianyu, 'last_price'):            send_dingtalk_message(f'闲鱼商品价格变动:{current_price}')            setattr(check_xianyu, 'last_price', current_price) # 钉钉机器人Webhook地址 dingtalk_webhook = 'https://oapi.dingtalk.com/robot/send?access_token=your_token' # 发送钉钉消息的函数 def send_dingtalk_message(message):    headers = {'Content-Type': 'application/json'}    data = {        "msgtype": "text",        "text": {            "content": message        }    }    response = requests.post(dingtalk_webhook, headers=headers, json=data)    if response.status_code == 200:        print('钉钉消息发送成功')    else:        print('钉钉消息发送失败') # 定时任务调度器 scheduler = BlockingScheduler() # 每1s检查一次闲鱼 scheduler.add_job(check_xianyu, 'interval', minutes=1s) if __name__ == '__main__':    scheduler.start() 

闲鱼助手稳定输出,特色功能,无需登陆账号,支持多钉钉推送,多关键词监控,排除关键词,捡漏商品价格区间自定义,发布时间自定义等功能,电脑端可打开商品链接扫码进入,手机端一键跳转商品界面,持续更新中闲鱼助手——监控解析_第1张图片

 

 

 

你可能感兴趣的:(闲鱼助手——监控解析)