Skip to content

Commit cff51da

Browse files
authored
Create smzdm.py
1 parent dd69511 commit cff51da

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

moumoubaimifan/smzdm/smzdm.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
import requests
3+
from bs4 import BeautifulSoup
4+
import time
5+
6+
userAgent = {
7+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
8+
}
9+
10+
def parse_html(event, context):
11+
now = time.time()
12+
authorIds = ['1222805984']
13+
for author in authorIds:
14+
url = 'https://zhiyou.smzdm.com/member/' + author + '/baoliao/'
15+
16+
17+
html_content = requests.get(url, headers = userAgent).content
18+
19+
soup = BeautifulSoup(html_content, 'html.parser', from_encoding='utf-8')
20+
infos = soup.find_all(name='div',attrs={'class': 'pandect-content-stuff'})
21+
22+
23+
for info in infos:
24+
a = info.find(name='div', attrs={'class': 'pandect-content-title'}).a
25+
t = info.find(name='span', attrs={'class': 'pandect-content-time'}).text
26+
27+
# 只推送 5分钟之内的爆料
28+
content_time = time.mktime(time.strptime('2021-' + t + ':00', "%Y-%m-%d %H:%M:%S"))
29+
if((now - content_time) < 5 * 60):
30+
content = a.text.strip() + '\r\n' + a['href']
31+
push_qmsg(content)
32+
33+
34+
def push_qmsg(msg):
35+
key = 'xxx'
36+
url = 'https://qmsg.zendee.cn/send/' + key
37+
msg = {'msg': msg}
38+
requests.post(url, params=msg)

0 commit comments

Comments
 (0)