-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget2.py
More file actions
48 lines (35 loc) · 976 Bytes
/
get2.py
File metadata and controls
48 lines (35 loc) · 976 Bytes
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
# !/usr/bin/env python3
# -*- coding: utf-8 -*-
###########################################
#
# 爬虫程序2.0版本 - 从文件中读取并解析json数据,提取需要的字段
#
# @Author: lordli
#
# @Date: 2020-09-17
#
# @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("开始分析今天是否有早报")
r=requests.get(url)
if (r.status_code == 200):
with open ('news.json', 'wb') as f:
f.write(r.content)
with open('news.json', 'r') as f:
data1 = json.load(f)
topics = data1['body']['datas']
for topic in topics:
result = re.findall(todayStr, topic['title'])
if result:
print (topic['shareImageInfos'])
else:
print("error")