Condition: répertorier les blogs abonnés à Feedly (notation markdown)
Obtenez le RSS auquel vous êtes abonné avec le lecteur RSS feedly.
Le contenu des données au format de fichier XML est le suivant.
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="Informations de mise à jour | Site officiel PlayStation" title="Informations de mise à jour | Site officiel PlayStation" xmlUrl="http://www.jp.playstation.com/whatsnew/whatsnew.rdf" htmlUrl="http://www.jp.playstation.com/index.html"/>
        </outline>
    </body>
</opml>
Python 2.5 ou supérieur (car Element Tree est inclus en standard)
xml_edit.py
#coding:utf-8
import xml.etree.ElementTree as ET
#Lire le fichier xml
tree = ET.parse('feedly.opml.xml')
root = tree.getroot()
#Catégorie que vous souhaitez afficher
category = 'Engineers Blog'
#Rechercher une cible à lancer pour tout trouver
find_el = ".//outline[@text='%s']/outline[@type='rss']" % category
es = root.findall(find_el)
for e in es:
    #Des données de type dictionnaire peuvent être obtenues.
    blog_data = e.attrib
    title = ""
    url = ""
    #Récupérez les données.
    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/)
Je l'ai eu avec Markdown, alors je l'ai posté sur mon blog. https://www.karumado.com/2014/05/feedly.html
Recommended Posts