• 薅羊毛须及时 多平台微信线报提醒脚本


    说明

    闲着也是闲着,一堆废旧手机好几个微信账号,每天薅个早餐钱吧。

    需求

    监控线报网站有线报更新发送微信信息提醒。

    from wxpy import *
    import platform,sqlite3,time,requests
    from bs4 import BeautifulSoup
    
    #微信机器人配置
    console_qr=(False if platform.system() == 'Windows' else True)
    bot = Bot('bot.pkl', console_qr=console_qr)
    tuling = Tuling('图灵接口自动回复')
    my_friend = bot.friends()
    tt = bot.groups().search('群名称')[0]
    
    @bot.register(tt)
    def send(msg):
        tt.send(msg)
    
    @bot.register(my_friend)
    def tuling_reply(msg):
        tuling.do_reply(msg)
    
    @bot.register(msg_types=FRIENDS)
    def auto_accept_friends(msg):
        new_friend = msg.card.accept()
        new_friend.send('您好,有什么可以帮您的吗?')
    
    #创建数据库
    #只采集链接和标题发送到微信群
    conn = sqlite3.connect("./xianbao.db", check_same_thread=False)
    cursor = conn.cursor()
    try:
        sql = 'CREATE TABLE xianbao(id integer primary key autoincrement, via text NOT NULL UNIQUE,title text,pubtime datetime) '
        cursor.execute(sql)
    except Exception as e:
        print("表已存在")
    finally:
        conn.commit()
    
    #线报采集以科学刀为例
    def kxdao():
        site = '科学刀'
        r = requests.get('https://www.kxdao.net/forum-42-1.html')
        html = r.text
        bs = BeautifulSoup(html,'lxml')
        links = bs.findAll('a',class_='s xst')
        for link in links:
            url = link['href']
            title = link.text
            pubtime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
            msg = title + '
    ' + url
            w = cursor.execute('INSERT INTO "xianbao" ("via", "title", "pubtime") VALUES (?, ?, ?)',
                           [url,title, pubtime])
            if w == True:
                print(msg)
                conn.commit()
    
    #设置间隔时间五分钟
    while 1:
        kxdao()
        time.sleep(300)
    
    
  • 相关阅读:
    AutoFac学习笔记
    AutoMapper学习笔记
    ROSLYN 查看C#方法执行次数
    log4net 动态创建文件名
    WPF可切换按钮,iOS风格
    咕咕咕
    贪吃的小J
    UK Day15
    UK Day15
    UK Day15
  • 原文地址:https://www.cnblogs.com/aosky/p/12036258.html
Copyright © 2020-2023  润新知