Last active
October 5, 2018 08:22
-
-
Save yoshikinoue/2d208173cea6712d933e to your computer and use it in GitHub Desktop.
feedlyのxmlをPythonで加工する。 ref: https://qiita.com/karumado/items/ec1cab6bb9e23e210116
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[hoge](http://hoge/) | |
[fuga](http://fuga/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[hoge](http://hoge/) | |
[fuga](http://fuga/) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import xml.etree.ElementTree as ET | |
#xmlファイルの読み込み | |
tree = ET.parse('feedly.opml.xml') | |
root = tree.getroot() | |
#出力したいカテゴリ | |
category = 'Engineers Blog' | |
#findallに投げる検索対象 | |
find_el = ".//outline[@text='%s']/outline[@type='rss']" % category | |
es = root.findall(find_el) | |
for e in es: | |
#辞書型のデータが得られる。 | |
blog_data = e.attrib | |
title = "" | |
url = "" | |
#データを取り出す。 | |
for key, value in blog_data.items(): | |
if key == 'title': | |
title = value | |
elif key == 'xmlUrl': | |
url = value | |
print "[%s](%s)" % (title, url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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="更新情報|プレイステーション オフィシャルサイト" title="更新情報|プレイステーション オフィシャルサイト" xmlUrl="http://www.jp.playstation.com/whatsnew/whatsnew.rdf" htmlUrl="http://www.jp.playstation.com/index.html"/> | |
</outline> | |
</body> | |
</opml> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment