Requirement: List blogs subscribed to feedly (markdown notation)
Get the RSS you subscribe to with the RSS reader feedly.
The contents of the data in XML file format are as follows.
xml feedly.opml.xml
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>xxxx subscriptions in feedly Cloud</title>
</head>
<body>
<outline text="game" title="game">
<outline type="rss" text="Update Information | PlayStation Official Site" title="Update Information | PlayStation Official Site" xmlUrl="http://www.jp.playstation.com/whatsnew/whatsnew.rdf" htmlUrl="http://www.jp.playstation.com/index.html"/>
</outline>
</body>
</opml>
Python 2.5 or higher (because Element Tree is included as standard)
xml_edit.py
#coding:utf-8
import xml.etree.ElementTree as ET
#Read xml file
tree = ET.parse('feedly.opml.xml')
root = tree.getroot()
#Category you want to output
category = 'Engineers Blog'
#Search target to throw to findall
find_el = ".//outline[@text='%s']/outline[@type='rss']" % category
es = root.findall(find_el)
for e in es:
#Dictionary type data can be obtained.
blog_data = e.attrib
title = ""
url = ""
#Retrieve data.
for key, value in blog_data.items():
if key == 'title':
title = value
elif key == 'xmlUrl':
url = value
print "[%s](%s)"%(title,url)
[hoge](http://hoge/)
[fuga](http://fuga/)
I got it with Markdown, so I posted it on my blog. https://www.karumado.com/2014/05/feedly.html
Recommended Posts