-
Notifications
You must be signed in to change notification settings - Fork 1
/
get6.py
70 lines (53 loc) · 2.08 KB
/
get6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
###########################################
#
# 爬虫程序6.0版本 - 正式推送数据
#
# @Author: lordli
#
# @Date: 2020-09-21
#
# @Python version: 3.7.7
#
# @Libary: pip install requests
#
###########################################
import time
import requests
import json
import re
todayStr = str(time.localtime().tm_mon) + "月" + str(time.localtime().tm_mday) + "日"
url = "https://www.jinrongbaguanv.com/jinba/index_articles/1"
print("开始分析今天是否有早报")
WXurl = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX0078&debug=1'
headers = {'content-type': "application/json"}
r=requests.get(url)
if (r.status_code == 200):
jsonData = json.loads(r.content)
topics = jsonData['body']['datas']
for topic in topics:
result = re.findall(todayStr, topic['title'])
if result:
formatStr = ''
groupList = topic['shareImageInfos']
for group in groupList:
formatStr = formatStr + '## **<font color=\"#BD286F\">' + group['title'] + '</font>** \n '
newslist = group['content']
for news in newslist:
formatStr = formatStr + ' #### - ' + news + '\n '
formatStr = formatStr + '\n '
formatStr = formatStr + '----------------------------\n '
formatStr = formatStr + '[如需了解更多,请点击此处](https://www.jinrongbaguanv.com/article/details.html?id='+ str(topic['id']) +')\n '
formatStr = formatStr + '----------------------------\n '
formatStr = formatStr + '<font color="comment">更多意见与建议,可企业微信:lordli</font> \n '
formatStr = {
"msgtype": "markdown",
"markdown": {
"content": formatStr }
}
response = requests.post(WXurl, json = formatStr, headers = headers)
print (response.text)
print (response.status_code)
else:
print("error")