Last active
March 2, 2016 13:48
-
-
Save kurozumi/688eaad931b1ea0ccb75 to your computer and use it in GitHub Desktop.
【Python】Seleniumを使ってRSSフィードのURLを探してRSSフィードをパースしてCSVに保存する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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