Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
【Python】Seleniumを使ってRSSフィードのURLを探してRSSフィードをパースしてCSVに保存する方法
# coding: utf-8
from selenium import webdriver
import re, feedparser, csv
driver = webdriver.Firefox()
driver.get("http://a-zumi.net")
for link in driver.find_elements_by_tag_name("link"):
if re.search('rss', link.get_attribute("type")) is not None:
response = feedparser.parse(link.get_attribute('href'))
for entry in response.entries:
with open(response.feed.title + ".csv", "a") as f:
csvWriter = csv.writer(f)
csvWriter.writerow([entry.title.encode('utf_8'), entry.link.encode('utf_8'), entry.updated.encode('utf_8')])
driver.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment