I almost got the sauce from here. [Search Make. Get RSS of the manufacturing site you want to make](http://make.bcde.jp/python/rss%E3%82%92%E5%8F%96%E5%BE%97%E3 % 81% 99% E3% 82% 8B /)
Use conda to install feedparser
conda install feedparser
Click here for documentation feedparser 5.2.0 documentation
get_feed.py
from datetime import datetime
from time import mktime
import feedparser
from tqdm import tqdm
from time import sleep
#RSS URL
RSS_URL = "http://www.fxstreet.jp/rss/news/forex-news/"
#Get RSS
feed = feedparser.parse(RSS_URL)
#RSS title
print(feed.feed.title, '\n')
while True:
try:
for entry in tqdm(range(len(feed.entries))):
#Process RSS contents one by one
title = feed.entries[entry].title
link = feed.entries[entry].link
#Get update date as a string
published_string = feed.entries[entry].published
#Get update date as datetime
tmp = feed.entries[entry].published_parsed
published_datetime = datetime.fromtimestamp(mktime(tmp))
#display
print(title)
print(link)
print(published_string)
print(published_datetime)
print('\n')
sleep(1)
except KeyboardInterrupt:
break
while True:
infinite looptry-except
time.sleep (1)
tqdm.tqdm
conda install -c conda-forge tqdm
TODO
BUGS
UnicodeEncodeError: 'cp932' codec can't encode character '\u20ac' in position 36: illegal multibyte sequence
Recommended Posts