2016-08-04 11:00:33 -07:00
|
|
|
from gevent import monkey
|
2024-04-24 09:43:56 -04:00
|
|
|
|
2016-08-04 11:00:33 -07:00
|
|
|
monkey.patch_socket()
|
|
|
|
|
2024-04-24 09:50:42 -04:00
|
|
|
import urllib.error
|
|
|
|
import urllib.parse
|
|
|
|
import urllib.request
|
|
|
|
|
2016-08-04 11:00:33 -07:00
|
|
|
import gevent
|
|
|
|
from gevent import queue
|
2024-04-24 09:50:42 -04:00
|
|
|
|
|
|
|
from newsblur.utils import feedparser
|
2016-08-04 11:00:33 -07:00
|
|
|
|
2024-04-24 09:43:56 -04:00
|
|
|
|
2016-08-04 11:00:33 -07:00
|
|
|
def fetch_title(url):
|
2020-06-15 05:09:10 -04:00
|
|
|
print(("Running %s" % url))
|
|
|
|
data = urllib.request.urlopen(url).read()
|
|
|
|
print(("Parsing %s" % url))
|
2016-08-04 11:00:33 -07:00
|
|
|
d = feedparser.parse(data)
|
2024-04-24 09:43:56 -04:00
|
|
|
print(("Parsed %s" % d.feed.get("title", "")))
|
|
|
|
return d.feed.get("title", "")
|
|
|
|
|
2016-08-04 11:00:33 -07:00
|
|
|
|
|
|
|
def worker():
|
|
|
|
while True:
|
|
|
|
url = q.get()
|
|
|
|
try:
|
|
|
|
fetch_title(url)
|
|
|
|
finally:
|
|
|
|
q.task_done()
|
|
|
|
|
2024-04-24 09:43:56 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2016-08-04 11:00:33 -07:00
|
|
|
q = queue.JoinableQueue()
|
|
|
|
for i in range(5):
|
2024-04-24 09:43:56 -04:00
|
|
|
gevent.spawn(worker)
|
2016-08-04 11:00:33 -07:00
|
|
|
|
2024-04-24 09:43:56 -04:00
|
|
|
for (
|
|
|
|
url
|
|
|
|
) in "http://www.43folders.com/rss.xml/nhttp://feeds.feedburner.com/43folders/nhttp://www.43folders.com/rss.xml/nhttp://feeds.feedburner.com/43folders/nhttp://feeds.feedburner.com/AMinuteWithBrendan/nhttp://feeds.feedburner.com/AMinuteWithBrendan/nhttp://www.asianart.org/feeds/Lectures,Classes,Symposia.xml/nhttp://www.asianart.org/feeds/Performances.xml/nhttp://feeds.feedburner.com/ajaxian/nhttp://ajaxian.com/index.xml/nhttp://al3x.net/atom.xml/nhttp://feeds.feedburner.com/AmericanDrink/nhttp://feeds.feedburner.com/eod_full/nhttp://feeds.feedburner.com/typepad/notes/nhttp://feeds.dashes.com/AnilDash/nhttp://rss.sciam.com/assignment-impossible/feed/nhttp://blogs.scientificamerican.com/assignment-impossible//nhttp://feeds.feedburner.com/Beautiful-Pixels/nhttp://feeds.feedburner.com/Beautiful-Pixels/nhttp://www.betabeat.com/feed/".split(
|
|
|
|
"/n"
|
|
|
|
):
|
|
|
|
print(("Spawning: %s" % url))
|
|
|
|
q.put(url)
|
2016-08-04 11:00:33 -07:00
|
|
|
|
|
|
|
q.join() # block until all tasks are done
|