吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 5870|回复: 59
收起左侧

[Python 转载] 摸鱼办+每日电影推荐+一步步教你创建第一个云函数

  [复制链接]
▓innovator 发表于 2021-12-7 16:40
本帖最后由 ▓innovator 于 2021-12-8 09:20 编辑

pushplsh账号创建
1.登陆pushplsh
image.png
2.选择一对多推(复制Token) 替换'token':'填写你的pushplus',
image.png

3.创建一个组群
image.png
4.查看二维码并扫描关注
image.png
5.代码里面'topic':'2' 替换成自己创建的组群编码,如我创建的是5,就是'topic':'5'


代码
[Python] 纯文本查看 复制代码
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


云函数创建
1.选择地区,点击新建
image.png
2.选择自定义模板---运行环境3.6--完成
image.png

3.将代码粘贴进去,点击部署--测试
image.png

4.测试成功后可以看到执行日志情况
image.png

5.创建触发器,定时发送信息
image.png

6.微信收到推送消息
下面是运行截图
1638866726(1).jpg

免费评分

参与人数 16吾爱币 +22 热心值 +16 收起 理由
imqiuge + 1 + 1 谢谢@Thanks!
disciable + 1 + 1 我很赞同!
孤霜情冷点朱砂 + 1 + 1 我很赞同!
zkl + 1 + 1 用心讨论,共获提升!
林大钦 + 1 + 1 鼓励转贴优秀软件安全工具和文档!
huahuaya + 1 + 1 我很赞同!
niuyifeng + 1 + 1 谢谢@Thanks!
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
GhostCN_Z + 1 + 1 老哥你可以把话术的api改成 一言 的,比较好
ailang + 1 + 1 我很赞同!
香芋 + 1 + 1 用心讨论,共获提升!
YaoXiaoJie + 1 + 1 我很赞同!
狂炫酷拽吊炸天 + 1 + 1 我很赞同!
GNC6B + 1 谢谢@Thanks!
chjihui + 1 + 1 文本有点意思,建议增加点励志的入去,不要太单调
李玉风我爱你 + 2 + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

tompanda 发表于 2021-12-10 16:19
本帖最后由 tompanda 于 2021-12-10 16:24 编辑

推送钉钉
钉钉机器人安全设置 关键字  摸鱼提醒

# -*- coding: utf8 -*-
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]+"\n"
        k=int(k)+1
     
    url = "http://wufazhuce.com/"
    wd=GetInfo(url)
    moyu=BuildContent(wd)
    str1=moyu + "每日新电影"+str1
    #url = "http://pushplus.hxtrip.com/send"
    #data={'token':'21c28ee68f91400fb634e97dce55bb94','title':'每日提示','content':str1,'template':'html','topic':'2'}
    url = "https://oapi.dingtalk.com/robot/send?access_token=钉钉token"
    data={"msgtype": "text","text": {"content": str1}}
    print(data)
    headers = {'Content-Type': 'application/json'}
    result = requests.post(url=url,headers=headers,data=json.dumps(data))
    print(result.text)

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 = "#【摸鱼提醒】"
    today = datetime.datetime.now()
    Today = "\n今天是" + str(today.year) + "年" + str(today.month) + "月" + str(today.day) + "日\n"
    Weekday = "距离本周周末还有" + str(6 - today.weekday() - 1) + "天\n"
    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) + "天" + '\n'
            
    text = "工作再累,一定不要忘记摸鱼哦!有事没事起身去茶水间,去厕所,去廊道走走别老在工位上坐着,钱是老板的,但命是自己的\n"
     
    HappyContent = title + Today  + text +Weekday + OtherHappy + (word)
    #print(HappyContent)
    return HappyContent

免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
▓innovator + 1 + 1 谢谢@Thanks!

查看全部评分

摇裤儿 发表于 2021-12-7 17:29
zxl1993 发表于 2021-12-7 17:37
大佬,怎么推送到企业微信,能否帮忙修改下
小沐沐警官 发表于 2021-12-7 17:47
填写对应的Token没反应,测试是成功的
busyjie 发表于 2021-12-7 18:09
不错不错,有意思
ynboyinkm 发表于 2021-12-7 18:13
这个可有意思了 !!!!!!!
zkl 发表于 2021-12-7 18:28
小沐沐警官 发表于 2021-12-7 17:47
填写对应的Token没反应,测试是成功的

我也是呢
小沐沐警官 发表于 2021-12-7 18:28

求解求解
xiaotian1339 发表于 2021-12-7 18:31
怎么推送到微信或者钉钉?求解
jingmoshell 发表于 2021-12-7 18:32
现在的云函数还是免费的吗/
好像有些功能收费了
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-24 11:55

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表