-
Notifications
You must be signed in to change notification settings - Fork 0
/
DaumNews.py
28 lines (20 loc) · 902 Bytes
/
DaumNews.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
import json
import time
import requests, time
from datetime import datetime
from bs4 import BeautifulSoup as bs
url_origin = "https://finance.daum.net/content/news?page=1&perPage=20&category=economy&searchType=all&keyword=A376180&pagination=true"
headers = {
'Referer': 'http://finance.daum.net',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 OPR/58.0.3135.127'
}
detail_url = "https://finance.daum.net/quotes/A376180#news/stock/"
response = requests.get(url_origin, headers=headers)
jsonObj = response.json()
for i in jsonObj['data'] :
date_time_obj = datetime.strptime(i['createdAt'], '%Y-%m-%d %H:%M:%S').date()
if date_time_obj == datetime.today().date():
print(i['newsId'], i['title'], i['summary'], i['imageUrl'])
for i in jsonObj['data'] :
print(detail_url + i['newsId'])
# print(jsonObj)