用python脚本自动提醒我,斗罗大陆更新了

哈哈哈,今天斗罗大陆更新了

日常上(需要科学)网站看 斗罗大陆,画质特别清晰
url = http://www.dmd8.com
发现到中午了还没更新...
头脑风暴,不如写脚本提醒我更新了?
脚本如下:

from parsel import Selector
import requests
"""
euv : python3
pip :   pip install parsel
        pip install requests
"""


def d8_dpcq(url):
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0',
        'Host': 'www.dmd8.com',
        'Referer': 'http://www.dmd8.com/index.php?m=vod-search-wd-%E6%96%97%E7%BD%97%E5%A4%A7%E9%99%86',
        'Connection': 'keep-alive',
        'Cache-Control': 'max-age=0',
    }
    selector = Selector(text=requests.get(url=url, headers=headers, timeout=10).text)
    select_url = selector.xpath('//font[@color="#AA3700"]/text()').get()
    return select_url[-3:]


def tx_dpcq(url):
    headers = {
        'cache-control': 'no-cache',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 '
                      '(KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',
    }
    selector = Selector(text=requests.get(url=url, headers=headers, timeout=10).text)
    select_url = selector.xpath('//span[@itemprop="episodeNumber"]/text()')
    select_data = (list(select_url)[-1]).get()
    return select_data


if __name__ == '__main__':
    url_d8 = 'http://www.dmd8.com/detail/586.html'
    url_tx = 'https://v.qq.com/detail/m/m441e3rjq9kwpsc.html'
    try:
        num = d8_dpcq(url_d8)
        if num == tx_dpcq(url_tx):
            print('斗罗大陆已更新到', str(num), "集\n观看地址: ", str(url_d8))
    except Exception as e:
        print("// 报错 ERR : \n", e)

这只是获取了数据,后续可以嵌套通知
通知方式有多种:mail ,钉钉 / 微信 机器人

posted @ 2020-09-05 17:44  运维之爪  阅读(927)  评论(0编辑  收藏  举报