Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# reading_time_estimator
Python script for estimating an article's reading time
this works with python3
6 changes: 4 additions & 2 deletions reading_time_estimator.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import bs4
import urllib, re
import sys

# 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 +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]))