-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from aaaandrzej/linting
Make flake8 happy
- Loading branch information
Showing
6 changed files
with
128 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
from audiobook.main import AudioBook | ||
|
||
__all__ = [ | ||
"AudioBook", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,37 @@ | ||
import requests | ||
from bs4 import BeautifulSoup | ||
|
||
|
||
class ArticleWebScraper: | ||
""" | ||
ArticleWebScraper class | ||
methods: | ||
get_json_from_web_article: returns a json from a non-empty <article> tag | ||
get_json_from_web_article: returns a json from a non-empty <article> tag # noqa: E501 | ||
get_title_from_article: returns the <title> tag from the html page | ||
sample usage: | ||
ab = AudioBook(speed="normal") | ||
ab.read_book(file_path, password="abcd") | ||
""" | ||
|
||
def __init__(self, article_url): | ||
page = requests.get(article_url) | ||
self.article_url = article_url | ||
self.soup = BeautifulSoup(page.content, "html.parser") | ||
|
||
def get_title_from_article (self): | ||
""" returns the <title> tag from the html page """ | ||
def get_title_from_article(self): | ||
"""returns the <title> tag from the html page""" | ||
return self.soup.title.text | ||
|
||
def get_page_data(self): | ||
""" returns a json from a non-empty <article> tag """ | ||
"""returns a json from a non-empty <article> tag""" | ||
response = requests.get(self.article_url) | ||
|
||
if response.status_code != 200: | ||
return None | ||
|
||
soup = BeautifulSoup(response.content, "html.parser") | ||
text_data = soup.getText().replace("\n","") | ||
|
||
text_data = soup.getText().replace("\n", "") | ||
return text_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
supported_file_types = (".pdf", ".txt", ".epub", ".docx", ".doc") | ||
speed_dict = { | ||
"slow": 100, | ||
"normal": 150, | ||
"fast": 200} | ||
speed_dict = {"slow": 100, "normal": 150, "fast": 200} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.