From 904dfde203dd2b70651cbe3055e536e968778c8c Mon Sep 17 00:00:00 2001 From: Rahul Vagadiya Date: Fri, 3 Jun 2022 12:29:33 +0400 Subject: [PATCH] Update reading_time_estimator.py Suggested changes for python3 --- reading_time_estimator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reading_time_estimator.py b/reading_time_estimator.py index 6bbea89..e719e6e 100644 --- a/reading_time_estimator.py +++ b/reading_time_estimator.py @@ -1,5 +1,5 @@ import bs4 -import urllib, re +import urllib.request, re # Words per minute WPM = 200 @@ -7,7 +7,7 @@ # 1 def extract_text(url): - html = urllib.urlopen(url).read() + html = urllib.request.urlopen(url).read() soup = bs4.BeautifulSoup(html, 'html.parser') texts = soup.findAll(text=True) return texts @@ -38,4 +38,4 @@ def estimate_reading_time(url): total_words = count_words_in_text(filtered_text, WORD_LENGTH) return total_words/WPM -print estimate_reading_time("http://www.assafelovic.com/blog/2017/6/27/estimating-an-articles-reading-time") +print(estimate_reading_time("http://www.assafelovic.com/blog/2017/6/27/estimating-an-articles-reading-time"))