Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions reading_time_estimator.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import bs4
import urllib, re
import urllib.request, re

# Words per minute
WPM = 200
WORD_LENGTH = 5

# 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
Expand Down Expand Up @@ -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"))