Created
March 18, 2015 05:15
-
-
Save nkt1546789/f0a0afebf25ddd2f4753 to your computer and use it in GitHub Desktop.
urlmulti.py makes url loading process faster using multiprocessing.
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 requests | |
def urlopen(url): | |
try: return requests.get(url).content | |
except: return None | |
def urlsopen(urls): | |
pool = Pool(processes=8) | |
return pool.map(urlopen, urls) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment