---- AI试用 ---域名问题某些图片和js资源无法访问,导致一些代码实例无法运行!(代码里gzui.net换成momen.vip即可)

摸鱼办提示+每日电影推荐+云函数

前端开发 蚂蚁 1192℃ 0评论

https://www.52pojie.cn/thread-1557356-1-1.html

import re
import requests
import json
import datetime

def main_handler(event, context):
    uel= "https://www.80s.tw/"
    aa=requests.get(uel)
    aa.encoding="utf-8"
    selector = aa.text
    getHtml = re.compile(r'<li>.*<a href="/movie/.*" title="\S*')
    selector = re.findall(getHtml, selector)
    str1 = ""
    k=1
    for i in selector:
        var = i.split('title="')
        str1 += str(k)+'.'+var[1]+"<br/>"
        k=int(k)+1

    url = "http://wufazhuce.com/"
    wd=GetInfo(url)
    moyu=BuildContent(wd)
    str1=moyu + "<h3>每日新电影</h3>"+str1
    url = "http://pushplus.hxtrip.com/send"
    data={'token':'填写你的pushplus','title':'每日提示','content':str1,'template':'html','topic':'2'}
    requests.post(url=url, data=json.dumps(data))

def GetInfo(url):
    headers = {"content-type": "application/json",
               "User-Agent": 'Mozilla/5.0 (X11;Ubuntu;Linux x86_64; rv:22.0) Gecko/20100101 Firefox'}
    page = requests.get(url, headers=headers).text
    getHtml = re.compile(r'<a href="http://wufazhuce.com/one/.*')
    word = re.findall(getHtml, page)
    word=word[1].split('>')[1].split('<')[0]
    return word

def BuildContent(word):
    title = "【摸鱼提醒】</br>"
    today = datetime.datetime.now()
    Today = "今天是" + str(today.year) + "年" + str(today.month) + "月" + str(today.day) + "日\n"+ '</br>'
    Weekday = "距离本周周末还有" + str(6 - today.weekday() - 1) + "天\n"+ '</br>'
    OtherHappy = ""
    map = ["2022-01-01,元旦", "2022-01-31,春节", "2022-04-03,清明", "2022-04-30,五一",
           "2022-06-03,端午", "2022-09-10,中秋", "2022-10-01,国庆"]

    for s in map:
        that = datetime.datetime.strptime(s.split(',')[0], '%Y-%m-%d')
        dayname = s.split(',')[1].replace("\n", "")
        if int((that - today).days + 1) > 0:
            OtherHappy += "距离" + dayname + "还有" + str((that - today).days + 1) + "天" + '</br>'

    text = "工作再累,一定不要忘记摸鱼哦!有事没事起身去茶水间,去厕所,去廊道走走别老在工位上坐着,钱是老板的,但命是自己的" + '</br>'

    HappyContent = title + Today  + text +Weekday + OtherHappy + (word+"</br>")
    print(HappyContent)
    return HappyContent

转载请注明:有爱前端 » 摸鱼办提示+每日电影推荐+云函数

喜欢 (2)or分享 (0)