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

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 6693|回复: 63
收起左侧

[Python 转载] 再小的羊毛也是钱,一直薅一直爽

[复制链接]
looking4freedom 发表于 2021-9-10 10:38
本帖最后由 looking4freedom 于 2021-9-11 10:28 编辑

二话不说直接上代码,我是用qmsg的api挂在腾讯云进行推送,触发时间的话最好选择下午或晚上,如果想换成其他推送方式的可以稍微改下代码即可

[Python] 纯文本查看 复制代码
import requests
from bs4 import BeautifulSoup
import time


def wool_message():
    headers = {
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36"
    }
    url = "https://www.youjiangzhijia.com/"
    html = requests.get(url=url, headers=headers).text
    soup = BeautifulSoup(html, 'lxml')
    articles = soup.find_all('article')
    content = ""

    for article in articles:
        article_info = list(article.stripped_strings)
        if (article_info[3] == str(time.strftime("%Y-%m-%d", time.localtime())) or article_info[2] == str(
                time.strftime("%Y-%m-%d", time.localtime()))) and (
                "活动网" in article_info[0] or "活动网" in article_info[1]):
            if article_info[0] == '置顶':
                content += article_info[2] + '\n'
            else:
                content += article_info[1] + '\n'
    qmsg_url = "https://qmsg.zendee.cn/send/key" # 自己的qmsg的key
    data = {
        "msg": "【有奖之家今日羊毛信息】:\n" + content,
        "qq": " " # 自己的QQ号
    }
    requests.post(url=qmsg_url, data=data)


def main():
    wool_message()


def main_handler(event, context):
    return main()


if __name__ == '__main__':
    main()


实现效果
QQ截图20210910103139.png

总结一下云函数各种报错解决:
1. no module bs4
解决方法:终端 cd 到 src目录执行 pip3 install BeautifulSoup4 -t .  后面有个点哦
2.lxml
用这个命令的话需要单独在src目录下pip install lxml,或者换一个解析器soup = BeautifulSoup(html, 'html.parser')
3.返回为null
说明今天还没更新

如果想要返回的信息有url链接的代码
[Python] 纯文本查看 复制代码
for article in articles:
   
    article_info = list(article.stripped_strings)
   
    if (article_info[3] == str(time.strftime("%Y-%m-%d", time.localtime())) or article_info[2] == str(
            time.strftime("%Y-%m-%d", time.localtime()))) and (
            "活动网" in article_info[0] or "活动网" in article_info[1]):
        res = re.findall(r'.*?href=(.*?) target="_blank', str(article))[0]

        if article_info[0] == '置顶':
            content += article_info[2] + res + '\n'
        else:
            content += article_info[1] + res + '\n'

不过不能用qmsg推送,会被诊断为商业行为,其他推送没有试过,有些应该可以

免费评分

参与人数 3吾爱币 +3 热心值 +3 收起 理由
与有荣焉 + 1 + 1 热心回复!
阿木木不哭 + 1 + 1 谢谢@Thanks!
xiliu1979827981 + 1 + 1 我很赞同!

查看全部评分

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

 楼主| looking4freedom 发表于 2021-9-10 13:25
现在以80、90后为代表的新兴都市族们对银行等金融机构及各类商家开展的一些优惠活动产生了浓厚兴趣,并专门出现了这样一批人,搜集各个银行等金融机构及各类商家的优惠信息,在网络和朋友圈子中广为传播,这种行为被称作薅(hāo)羊毛。
 楼主| looking4freedom 发表于 2021-9-10 21:36
与有荣焉 发表于 2021-9-10 20:08
在src目录是这样吗,但还是不行耶

[mw_shl_code=javascript,true]{

soup = BeautifulSoup(html, 'html.parser')
无名先森。 发表于 2021-9-10 11:22
蜉蝣SK 发表于 2021-9-10 11:23
感谢分享学习了
feichedang_caj 发表于 2021-9-10 11:28
感谢分享
 楼主| looking4freedom 发表于 2021-9-10 11:30
无名先森。 发表于 2021-9-10 11:22
能多添加几个通知api吗?比如TG、企业微信

我没怎么研究过这些 目前就只用过qmsg 钉钉之类的 空呢学习下
hackin 发表于 2021-9-10 11:34
就怕别人说推广告,直接拉黑
无名先森。 发表于 2021-9-10 11:40
looking4freedom 发表于 2021-9-10 11:30
我没怎么研究过这些 目前就只用过qmsg 钉钉之类的 空呢学习下

这个只有文本推送吗?如果有链接会更好一点
penz 发表于 2021-9-10 11:41
谢谢楼主,哈哈
戏子i丶 发表于 2021-9-10 11:45
哈哈哈哈,没看懂啥意思,是推广别人来薅羊毛嘛?我自己都不知道怎么找羊毛
知心 发表于 2021-9-10 12:02
无名先森。 发表于 2021-9-10 11:22
能多添加几个通知api吗?比如TG、企业微信

[Python] 纯文本查看 复制代码
def post_content(content):
	url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxx'
	headers = {
		"Content-Type": "application/json;charset=utf-8 "
	}

	# 准备文本消息
	msg_data= {
		"msgtype": "text",
		"text": {
			"content":content ,
			}
		}

	msg_data = json.dumps(msg_data)
	res = requests.post(url, data=msg_data, headers=headers)


url换成自己机器人的
挺简单的呀,自己类比的搞一下就行
您需要登录后才可以回帖 登录 | 注册[Register]

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

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

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

GMT+8, 2024-4-24 02:20

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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