diff --git a/newspaper/images.py b/newspaper/images.py index 54e5b1e1..4ee67d39 100644 --- a/newspaper/images.py +++ b/newspaper/images.py @@ -12,7 +12,6 @@ import math import io import traceback -import urllib.request import urllib.parse import urllib.error @@ -86,6 +85,7 @@ def clean_url(url): def fetch_url(url, useragent, referer=None, retries=1, dimension=False): + import urllib.request cur_try = 0 nothing = None if dimension else (None, None) url = clean_url(url) diff --git a/newspaper/utils.py b/newspaper/utils.py index 86f299cf..6033af19 100644 --- a/newspaper/utils.py +++ b/newspaper/utils.py @@ -268,7 +268,7 @@ def memoize_articles(source, articles): return [] memo = {} - cur_articles = {article.url: article for article in articles} + cur_articles = dict([(article.url, article) for article in articles]) d_pth = os.path.join(settings.MEMO_DIR, domain_to_filename(source_domain)) if os.path.exists(d_pth):