Created
August 23, 2016 14:54
-
-
Save kurozumi/44a5bdb422f0558466556fa621c2766f to your computer and use it in GitHub Desktop.
【Python】RSSフィードをマルチプロセス(並列処理)で取得する方法
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
from multiprocessing import Pool | |
import feedparser | |
feeds=[ | |
"http://www.yahoo.co.jp", | |
"https://www.google.co.jp", | |
"http://www.rakuten.co.jp", | |
"https://www.amazon.co.jp" | |
] | |
def feedparse(url): | |
rss = feedparser.parse(url) | |
for entry in rss.entries: | |
print(entry.title) | |
#最大プロセス数:10 | |
p = Pool(10) | |
p.map(feedparse, feeds) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment