Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active March 2, 2016 13:48
Show Gist options
  • Save kurozumi/688eaad931b1ea0ccb75 to your computer and use it in GitHub Desktop.
Save kurozumi/688eaad931b1ea0ccb75 to your computer and use it in GitHub Desktop.
【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