Last active
November 29, 2016 06:07
-
-
Save ixna/0771932e90aaf9ebbae3c286e26ddc82 to your computer and use it in GitHub Desktop.
Get rss sequence way
This file contains hidden or 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
import time | |
import requests | |
RSS_LIST = [ | |
'http://feeds.nytimes.com/nyt/rss/HomePage', | |
'http://www.washingtonpost.com/rss/', | |
'http://hosted.ap.org/lineups/USHEADS-rss_2.0.xml?SITE=RANDOM&SECTION=HOME', | |
'http://www.npr.org/rss/rss.php?id=1001', | |
'http://feeds.reuters.com/reuters/topNews'] | |
def some_process(): | |
time.sleep(1) | |
def run(): | |
result = [] | |
for rss_address in RSS_LIST: | |
print("Processing address %s" % (rss_address)) | |
response = requests.get(rss_address, timeout=3) | |
# Some process that takes 1 second | |
some_process() | |
result.append(response.content) | |
return result | |
if __name__ == "__main__": | |
start = time.time() | |
rss_data = run() | |
total_time = time.time() - start | |
print("Selesai get rss data secara sequence %s" % (total_time,)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment