Home / Geral / Parseando RSS usando Python
Geral

Parseando RSS usando Python

Mais um post daqueles tutoriais ultra-fast. Neste mostrarei como fazer um parser de rss usando o Python. Veja a simplicidade do código
import urllib import sys import xml.dom.minidom # The URL of the RSS feed address = 'http://rss.slashdot.org/Slashdot/slashdot' # Our actual XML document document = xml.dom.minidom.parse(urllib.urlopen(address)) for item in document.getElementsByTagName('item'): title = item.getElementsByTagName('title')[0].firstChild.data link = item.getElementsByTagName('link')[0].firstChild.data creator = item.getElementsByTagName('dc:creator')[0].firstChild.data print '''<a href="%s">%s</a> (%s)''' % (link.encode('UTF8', 'replace'), title.encode('UTF8','replace'), creator.encode('UTF8', 'replace'))
A

Escrito por Admin

Autor e especialista em tecnologia publicando reflexões e conhecimentos sobre inovação e desenvolvimento.

← Post Anterior Exibindo alertas em janelas Popup no Windows Próximo Post → Executando comando shell no Python