better progress output

This commit is contained in:
Nick Sweeting 2019-02-06 22:06:21 -08:00
parent 33ba29ea90
commit 56d382235f
5 changed files with 28 additions and 29 deletions

View file

@ -233,8 +233,9 @@ def fetch_page_title(url, default=True):
default = url
try:
sys.stdout.write('.')
sys.stdout.flush()
if SHOW_PROGRESS:
sys.stdout.write('.')
sys.stdout.flush()
html_content = urllib.request.urlopen(url, timeout=10).read().decode('utf-8')
match = re.search('<title>(.*?)</title>', html_content)
return match.group(1) if match else default or None