Skip to content

Instantly share code, notes, and snippets.

@chadmiller
Last active June 10, 2018 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chadmiller/7350c3a6cddd102be3cc31165602f3f6 to your computer and use it in GitHub Desktop.
Save chadmiller/7350c3a6cddd102be3cc31165602f3f6 to your computer and use it in GitHub Desktop.
OH HAI AYAN
#!/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