一直用的帖子推送到Tg,主要是tg api接口开放,操作简单粗暴,好用,就是需要上网代理,今天有空稍微修改了一下,让其推送到微信,30秒推送一次
操作步骤:
第一步:关注server酱,然后按照提示点击登录,然后绑定,获得key的类似于这样的格式:https://sc.ftqq.com/SCU63887T9e4*********************e50af2.send
第二步:替换一下代码中第34行链接,ojbk,再也不用担心有福利活动喝不到汤了,(我觉得维信推送垃圾的一比,推送信息可用资源太少,还有广告,看着就烦)
我建议关注tg机器人吧,毕竟发送内容是一样的,只需要请求一次,如果大家都去跑脚本,论坛表示压力很大
效果图如下:
附上python代码(python3,安装requests和lxml库):
- # -*- encoding: utf-8 -*-
- import requests
- from requests.adapters import HTTPAdapter
- import js2py
- import re
- from lxml import etree
- import time
- def getcookies():
- url = ‘/forum.php?mod=forumdisplay&fid=45&filter=author&orderby=dateline’
- js = js2py.EvalJs()
- headers = {‘user-agent’: ‘Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36’}
- try:
- aesjs = requests.get("/aes.min.js", headers=headers, timeout=5).text
- except Exception:
- return ‘ReturnNothing’
- js.execute(aesjs)
- getcookie = requests.get(url).text
- getcookie_script = re.findall("<script>(.*?)</script>",getcookie)
- js.execute(getcookie_script[0].split("document")[0])
- data = js.toHex(js.slowAES.decrypt(js.c, 2, js.a, js.b))
- cookie = "L7DFW=" + data
- print(cookie)
- return cookie
- hostloc_list = {"hello"}
- cookiestr = getcookies()
- try:
- while True:
- post_url = ‘https://sc.ftqq.com/SCU63887T9e4e136f886e82***********************2.send?’
- url = ‘/forum.php?mod=forumdisplay&fid=45&filter=author&orderby=dateline’
- headers = {
- ‘user-agent’: ‘Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36’}
- requests.adapters.DEFAULT_RETRIES = 5
- s = requests.session()
- s.keep_alive = False
- result = ‘L7DFW’ in cookiestr
- if result:
- headers = {‘Cookie’: cookiestr, ‘user-agent’: ‘Mozilla/5.0 (Linux; Android 6.0; ‘
- ‘Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome’
- ‘/46.0.2490.76 Mobile Safari/537.36’}
- r = s.get(url, headers=headers)
- else:
- r = s.get(url, headers=headers)
- xmlContent = etree.HTML(r.content)
- hrefList = xmlContent.xpath("//div[@class=’threadlist’]/ul/li/a/text()")
- author = xmlContent.xpath("//span[@class=’by’]/text()")
- number = xmlContent.xpath("//span[@class=’num’]/text()")
- href = xmlContent.xpath("//div[@class=’threadlist’]/ul/li/a/@href")
- for i in range(len(number)):
- if number[i] == ‘0’:
- if str(hrefList[i * 2].replace("\r\n", "")) not in hostloc_list:
- hostloc_list.add(str(hrefList[i * 2].replace("\r\n", "")))
- text = hrefList[i * 2].replace("\r\n", "")
- pid = re.findall(r’\d{6}’, href[i])
- url = "/thread-{}-1-1.html".format(int(pid[0]))
- text_url = post_url + "text=" + text + " by " + author[i] + ‘&desp=[点击打开链接](‘ + url + ")"
- requests.get(text_url)
- else:
- pass
- else:
- pass
- time.sleep(30)
- except Exception:
- pass
复制代码
安徽网友:很需要,感谢!
新疆网友:好东西,试试看
浙江网友:30秒太频繁了
我的都设置五分钟 足够了
天津网友:先马克一下
已经用mjj 15秒扫一次的tg了 暂时够用
香港网友:战略马克一下,一直用的TG
吉林网友:好东西哦
吉林网友:实际发现30s确实太频繁了,没那么多新帖子,我设置的两分钟
浙江网友:大佬我没懂,得到key之后
替换一下代码中第34行链接,然后怎么ojbk?
这段代码怎么用啊?
挂到甲骨文Linux 小鸡里运行这个代码吗?
澳门网友:/forum.php?mod=rss&auth=0
黑龙江网友:/forum.php?mod=rss&auth=0
广东网友:
我一般也不用 rss 了,只是偶尔用下命令看看:
curl -s ‘/forum.php?mod=rss&auth=0’ | awk ‘/<link>/{gsub("[ ]*</?link>[ ]*","");a=$0};/<title>/{gsub("[ ]*</?title>[ ]*","");b=$0};/<\/item>/{print a"\t"b;a=b=""}’ IGNORECASE=1 a=b=""
所以我不清楚 RSS 阅读器的情况
未经允许不得转载:美国VPS_搬瓦工CN2 GIA VPS » 论坛帖子推送到微信