David Blume's GitList
Repositories
testpython.git
Code
Commits
Branches
Tags
Search
Tree:
a9bb073
Branches
Tags
main
python2
testpython.git
sitesize
sitesize.py
Update URLs to new Raymond Hettinger sites.
David Blume
commited
a9bb073
at 2020-12-27 10:13:03
sitesize.py
Blame
History
Raw
#!/usr/bin/env python # https://pybay.com/site_media/slides/raymond2017-keynote/process.html from __future__ import print_function import urllib sites = [ # 'https://www.yahoo.com/', # 'http://www.cnn.com', # 'http://www.python.org', # 'http://www.jython.org', 'http://www.pypy.org', # 'http://www.perl.org', # 'http://www.cisco.com', # 'http://www.facebook.com', # 'http://www.twitter.com', # 'http://www.macrumors.com/', # 'http://arstechnica.com/', # 'http://www.reuters.com/', # 'http://abcnews.go.com/', # 'http://www.cnbc.com/', ] def sitesize(url): ''' Determine the size of a website ''' # TODO: Use requests instead, or migrate to python3 f = urllib.urlopen(url) # Could use "with" in python3 page = f.read() f.close() return url, len(page) def run(): for result in map(sitesize, sites): print(result) if __name__ == '__main__': run()