Last active
June 10, 2018 21:14
-
-
Save chadmiller/7350c3a6cddd102be3cc31165602f3f6 to your computer and use it in GitHub Desktop.
OH HAI AYAN
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
#!/usr/bin/env python3 | |
from urllib import request, error as urlliberror | |
from bs4 import BeautifulSoup as BS | |
import multiprocessing | |
from contextlib import suppress | |
def get_title(url): | |
with suppress(urlliberror.HTTPError): | |
page = request.urlopen(url) | |
return BS(page, "lxml").title.text | |
def FetchTitle(*urls): | |
with multiprocessing.Pool() as pool: | |
return pool.map(get_title, urls) | |
if __name__ == "__main__": | |
import sys | |
print(list(FetchTitle(*sys.argv[1:]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment