diff --git a/README.md b/README.md new file mode 100644 index 0000000..4b39eef --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# reading_time_estimator +Python script for estimating an article's reading time + this works with python3 diff --git a/reading_time_estimator.py b/reading_time_estimator.py index 6bbea89..2161cbd 100644 --- a/reading_time_estimator.py +++ b/reading_time_estimator.py @@ -1,5 +1,6 @@ import bs4 import urllib, re +import sys # Words per minute WPM = 200 @@ -7,7 +8,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 +39,5 @@ 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(sys.argv[1]))