Scraping RSS with Python

Use the lxml.etree module

Official

import lxml.etree

#Read the file
tree = lxml.etree.parse('rss2.xml')
#getroot()Corresponds to the XML root element in the method
root = tree.getroot()

#xpath()Get a list of elements that match the XPath in the method
for item in room.xpath('Specify elements hierarchically'):
#Specify the data you want to acquire and acquire

Use feedparser

You can scrape without being aware of the RSS format. There are multiple formats for RSS feeds, such as RSS1.0, RSS2.0, and Atom, which is annoying, so I recommend it.

Official

Get qiita articles tagged with Docker

import feedparser

d = feedparser.parse('https://qiita.com/tags/docker/feed')

for entry in d.entries:
    print(entry.link, entry.title)

It's so easy ... You can run it regularly and make your own RSS reader. ..

Recommended Posts

Scraping RSS with Python
Scraping with Python (preparation)
Try scraping with Python.
Scraping with Python + PhantomJS
Scraping with Selenium [Python]
Scraping with Python + PyQuery
I tried scraping with Python
Scraping with selenium in Python
Scraping with chromedriver in python
Festive scraping with Python, scrapy
Generate XML (RSS) with Python
Scraping with Selenium in Python
Scraping with Tor in Python
[Scraping] Python scraping
Scraping weather forecast with python
Scraping with Selenium + Python Part 2
I tried scraping with python
Web scraping beginner with python
Try scraping with Python + Beautiful Soup
Web scraping with Python ① (Scraping prior knowledge)
Scraping with Selenium in Python (Basic)
Scraping with Python, Selenium and Chromedriver
Web scraping with Python First step
I tried web scraping with python.
Scraping with Python and Beautiful Soup
Let's do image scraping with Python
Get Qiita trends with Python scraping
"Scraping & machine learning with Python" Learning memo
Python scraping notes
Scraping with selenium
Scraping with selenium ~ 2 ~
Statistics with python
Python with Go
Twilio with Python
Integrate with Python
Python Scraping eBay
Play with 2016-Python
AES256 with python
Tested with Python
Scraping with Selenium
python starts with ()
Python Scraping get_title
with syntax (Python)
Python: Scraping Part 1
Bingo with python
Zundokokiyoshi with python
Scraping using Python
Excel with Python
Microcomputer with Python
Python: Scraping Part 2
Cast with python
Get property information by scraping with python
WEB scraping with Python (for personal notes)
Automate simple tasks with Python Part1 Scraping
Getting Started with Python Web Scraping Practice
I tried scraping Yahoo News with Python
Web scraping with Python ② (Actually scraping stock sites)
Horse Racing Site Web Scraping with Python
Getting Started with Python Web Scraping Practice
Try HTML scraping with a Python library
Scraping from an authenticated site with python