This application is Python RSS-reader. It is implemented to read news from a given feed with prescribed arguments.
The application requires the next Python libraries to be installed:
fpdf
requests
beautifulsoup4
lxml
jsonlines
python-dateutil
colorama
Necessary libraries may be installed by entering the next command in a command line:
pip install library_name
User can run the application from a command line (from a folder, where scripts of rss_reader are situated) in two ways:
- running the script itself (if all requirements are installed) by a command:
python rss_reader.py source [--version] [--json] [--verbose] [--limit LIMIT] [--date DATE] [--html HTML] [--pdf PDF] [-h]
positional arguments:- source
- RSS URL
- --version
- Print version info
- --json
- Print result as JSON in stdout
- --verbose
- Outputs verbose status messages
- --limit LIMIT
- Limit news topics if this parameter provided
- --date DATE
- Print result from a cash for a given date
- --html HTML
- Print result to HTML file
- --pdf PDF
- Print result to PDF file
- -h, --help
- Show a help message and exit
- installing of application by a command:
python setup.py develop
The application may be then run by a command:
rss_reader source [--version] [--json] [--verbose] [--limit LIMIT] [--date DATE] [--html HTML] [--pdf PDF] [-h]
This application generates JSON with the next structure:
{"feed": "Name of sourse feed",
"news": [
{
"title": "title of news_1",
"pubdate": "publication date of a news_1",
"link": "sourse link for a news_1",
"description": "Short description of a content of a news_1"
},
{
"title": "title of news_2",
"pubdate": "publication date of a news_2",
"link": "sourse link for a news_2",
"description": "Short description of a content of a news_2"
},
...
]}
A cashed news storage is provided by a file dates.json and folders cashed_feeds and cashed_img.
When rss_reader is started without a --date argument, dates of publication of news are stored in the file dates.json together with path to file, where all news for this date are stored. All news (including title, link, date of publication, description, feed name, URL of media content, if a new has it, and path to media file in storage) are stored in the folder cashed_feeds. Media content of stored news is stored in the folder cashed_img. Names of files in the folder cashed_feeds corresponds to dates of publication of news.
When rss_reader is started with --date argument, it reads news from the cash for entered date and source.
A folder font contains a font for creating a PDF result file. A file rss_downloads.html contains initial template for creating a HTML result file.
User can run tests from a command line (from a folder, where scripts of rss_reader are situated) by a command:
python -m unittest discover