2017-03-19 08:36:32 +00:00
|
|
|
# Morss - Get full-text RSS feeds
|
2013-02-25 15:40:51 +00:00
|
|
|
|
2021-12-06 07:31:17 +00:00
|
|
|
[Homepage](https://morss.it/) •
|
2021-12-06 19:50:43 +00:00
|
|
|
[Upstream source code](https://git.pictuga.com/pictuga/morss) •
|
2021-12-06 07:31:17 +00:00
|
|
|
[Github mirror](https://github.com/pictuga/morss) (for Issues & Pull requests)
|
2020-03-19 22:04:21 +00:00
|
|
|
|
2021-12-10 11:58:20 +00:00
|
|
|
[![Build Status](https://ci.pictuga.com/api/badges/pictuga/morss/status.svg)](https://ci.pictuga.com/pictuga/morss)
|
|
|
|
[![Github Stars](https://img.shields.io/github/stars/pictuga/morss?logo=github)](https://github.com/pictuga/morss/stargazers)
|
|
|
|
[![Github Forks](https://img.shields.io/github/forks/pictuga/morss?logo=github)](https://github.com/pictuga/morss/network/members)
|
2021-12-16 09:03:43 +00:00
|
|
|
[![GNU AGPLv3 code](https://img.shields.io/static/v1?label=license&message=AGPLv3)](https://git.pictuga.com/pictuga/morss/src/branch/master/LICENSE)
|
|
|
|
[![Logo is CC BY-NC-SA 4.0](https://img.shields.io/static/v1?label=CC&message=BY-NC-SA%204.0)](https://creativecommons.org/licenses/by-nc-sa/4.0/)
|
2021-12-05 19:31:44 +00:00
|
|
|
|
2015-08-29 10:45:36 +00:00
|
|
|
This tool's goal is to get full-text RSS feeds out of striped RSS feeds,
|
|
|
|
commonly available on internet. Indeed most newspapers only make a small
|
|
|
|
description available to users in their rss feeds, which makes the RSS feed
|
|
|
|
rather useless. So this tool intends to fix that problem.
|
2013-02-25 20:49:38 +00:00
|
|
|
|
2015-08-29 10:45:36 +00:00
|
|
|
This tool opens the links from the rss feed, then downloads the full article
|
|
|
|
from the newspaper website and puts it back in the rss feed.
|
2014-05-21 10:09:50 +00:00
|
|
|
|
2015-08-29 10:45:36 +00:00
|
|
|
Morss also provides additional features, such as: .csv and json export, extended
|
|
|
|
control over output. A strength of morss is its ability to deal with broken
|
|
|
|
feeds, and to replace tracking links with direct links to the actual content.
|
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
Morss can also generate feeds from html and json files (see `feeds.py`), which
|
2015-08-29 10:45:36 +00:00
|
|
|
for instance makes it possible to get feeds for Facebook or Twitter, using
|
|
|
|
hand-written rules (ie. there's no automatic detection of links to build feeds).
|
|
|
|
Please mind that feeds based on html files may stop working unexpectedly, due to
|
|
|
|
html structure changes on the target website.
|
|
|
|
|
2020-04-05 20:20:33 +00:00
|
|
|
Additionally morss can detect rss feeds in html pages' `<meta>`.
|
2015-08-29 10:45:36 +00:00
|
|
|
|
2018-09-30 19:56:03 +00:00
|
|
|
You can use this program online for free at **[morss.it](https://morss.it/)**.
|
2013-04-15 16:51:55 +00:00
|
|
|
|
2018-09-30 19:56:30 +00:00
|
|
|
Some features of morss:
|
2020-10-01 20:25:53 +00:00
|
|
|
|
2018-09-30 19:56:30 +00:00
|
|
|
- Read RSS/Atom feeds
|
|
|
|
- Create RSS feeds from json/html pages
|
|
|
|
- Export feeds as RSS/JSON/CSV/HTML
|
|
|
|
- Fetch full-text content of feed items
|
|
|
|
- Follow 301/meta redirects
|
|
|
|
- Recover xml feeds with corrupt encoding
|
|
|
|
- Supports gzip-compressed http content
|
2022-12-13 21:40:13 +00:00
|
|
|
- HTTP caching with different backends (in-memory/redis/diskcache)
|
2018-09-30 19:56:30 +00:00
|
|
|
- Works as server/cli tool
|
|
|
|
- Deobfuscate various tracking links
|
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
## Install
|
|
|
|
|
|
|
|
### Python package
|
|
|
|
|
2021-12-16 09:03:43 +00:00
|
|
|
![Build Python](https://img.shields.io/badge/dynamic/json?label=build%20python&query=$.stages[?(@.name=='python')].status&url=https://ci.pictuga.com/api/repos/pictuga/morss/builds/latest)
|
|
|
|
[![PyPI](https://img.shields.io/pypi/v/morss)](https://pypi.org/project/morss/)
|
2021-12-14 09:45:38 +00:00
|
|
|
[![PyPI Downloads](https://img.shields.io/pypi/dm/morss)](https://pypistats.org/packages/morss)
|
2021-12-10 11:58:20 +00:00
|
|
|
|
2021-09-11 19:35:14 +00:00
|
|
|
Simple install (without optional dependencies)
|
|
|
|
|
2021-12-05 18:25:02 +00:00
|
|
|
From pip
|
|
|
|
|
|
|
|
```shell
|
|
|
|
pip install morss
|
|
|
|
```
|
|
|
|
|
|
|
|
From git
|
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
```shell
|
|
|
|
pip install git+https://git.pictuga.com/pictuga/morss.git
|
|
|
|
```
|
|
|
|
|
2021-09-11 19:35:14 +00:00
|
|
|
Full installation (including optional dependencies)
|
2013-06-19 19:12:03 +00:00
|
|
|
|
2021-12-05 18:25:02 +00:00
|
|
|
From pip
|
|
|
|
|
|
|
|
```shell
|
|
|
|
pip install morss[full]
|
|
|
|
```
|
|
|
|
|
|
|
|
From git
|
|
|
|
|
2021-09-11 19:35:14 +00:00
|
|
|
```shell
|
2021-11-23 19:09:52 +00:00
|
|
|
pip install git+https://git.pictuga.com/pictuga/morss.git#egg=morss[full]
|
2021-09-11 19:35:14 +00:00
|
|
|
```
|
2015-08-29 10:45:36 +00:00
|
|
|
|
2023-06-25 23:30:47 +00:00
|
|
|
The full install includes all the cache backends. Otherwise, only in-memory
|
|
|
|
cache is available. The full install also includes gunicorn (for more efficient
|
|
|
|
HTTP handling).
|
2013-06-19 19:12:03 +00:00
|
|
|
|
2021-09-11 19:35:14 +00:00
|
|
|
The dependency `lxml` is fairly long to install (especially on Raspberry Pi, as
|
|
|
|
C code needs to be compiled). If possible on your distribution, try installing
|
|
|
|
it with the system package manager.
|
2020-10-01 20:25:53 +00:00
|
|
|
|
|
|
|
### Docker
|
|
|
|
|
2021-12-16 09:03:43 +00:00
|
|
|
![Build Docker](https://img.shields.io/badge/dynamic/json?label=build%20docker&query=$.stages[?(@.name=='docker')].status&url=https://ci.pictuga.com/api/repos/pictuga/morss/builds/latest)
|
|
|
|
[![Docker Hub](https://img.shields.io/docker/pulls/pictuga/morss)](https://hub.docker.com/r/pictuga/morss)
|
|
|
|
[![Docker Arch](https://img.shields.io/badge/dynamic/json?color=blue&label=docker%20arch&query=$.results[0].images[*].architecture&url=https://hub.docker.com/v2/repositories/pictuga/morss/tags)](https://hub.docker.com/r/pictuga/morss/tags)
|
2021-12-10 11:58:20 +00:00
|
|
|
|
2021-12-05 19:28:03 +00:00
|
|
|
From docker hub
|
|
|
|
|
|
|
|
With cli
|
|
|
|
|
|
|
|
```shell
|
|
|
|
docker pull pictuga/morss
|
|
|
|
```
|
|
|
|
|
2022-12-13 21:07:21 +00:00
|
|
|
With docker-compose **(recommended)**
|
2021-12-05 19:28:03 +00:00
|
|
|
|
|
|
|
```yml
|
|
|
|
services:
|
|
|
|
app:
|
|
|
|
image: pictuga/morss
|
|
|
|
ports:
|
|
|
|
- '8000:8000'
|
|
|
|
```
|
|
|
|
|
|
|
|
Build from source
|
|
|
|
|
|
|
|
With cli
|
2015-08-29 10:45:36 +00:00
|
|
|
|
2020-03-20 10:33:52 +00:00
|
|
|
```shell
|
2020-10-03 20:18:51 +00:00
|
|
|
docker build --tag morss https://git.pictuga.com/pictuga/morss.git --no-cache --pull
|
2020-03-20 10:33:52 +00:00
|
|
|
```
|
2014-06-21 14:38:48 +00:00
|
|
|
|
2021-12-05 19:28:03 +00:00
|
|
|
With docker-compose
|
2020-04-28 19:58:26 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
```yml
|
|
|
|
services:
|
|
|
|
app:
|
|
|
|
build: https://git.pictuga.com/pictuga/morss.git
|
|
|
|
image: morss
|
|
|
|
ports:
|
2021-10-19 20:19:59 +00:00
|
|
|
- '8000:8000'
|
2020-10-01 20:25:53 +00:00
|
|
|
```
|
2015-08-29 10:45:36 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
Then execute
|
2013-06-19 19:12:03 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
```shell
|
2020-10-03 20:18:51 +00:00
|
|
|
docker-compose build --no-cache --pull
|
2020-10-01 20:25:53 +00:00
|
|
|
```
|
2013-11-16 16:48:21 +00:00
|
|
|
|
2021-11-21 21:38:26 +00:00
|
|
|
### Cloud providers
|
|
|
|
|
|
|
|
One-click deployment:
|
|
|
|
|
2021-12-10 15:11:57 +00:00
|
|
|
[![Heroku](https://img.shields.io/static/v1?label=deploy%20to&message=heroku&logo=heroku&color=79589F)](https://heroku.com/deploy?template=https://github.com/pictuga/morss)
|
|
|
|
[![Google Cloud](https://img.shields.io/static/v1?label=deploy%20to&message=google&logo=google&color=4285F4)](https://deploy.cloud.run/?git_repo=https://github.com/pictuga/morss.git)
|
2021-11-21 21:38:26 +00:00
|
|
|
|
2021-11-22 20:53:18 +00:00
|
|
|
Providers supporting `cloud-init` (AWS, Oracle Cloud Infrastructure), based on Ubuntu:
|
2021-11-21 21:38:26 +00:00
|
|
|
|
|
|
|
``` yml
|
|
|
|
#cloud-config
|
|
|
|
|
|
|
|
packages:
|
2021-11-23 19:13:40 +00:00
|
|
|
- python3-pip
|
2021-11-30 21:43:05 +00:00
|
|
|
- python3-wheel
|
2021-11-23 19:13:40 +00:00
|
|
|
- python3-lxml
|
2021-12-11 17:50:28 +00:00
|
|
|
- python3-setproctitle
|
2021-11-21 21:38:26 +00:00
|
|
|
- ca-certificates
|
|
|
|
|
|
|
|
write_files:
|
2021-11-22 20:53:18 +00:00
|
|
|
- path: /etc/environment
|
2021-12-25 10:02:27 +00:00
|
|
|
append: true
|
2021-11-21 21:38:26 +00:00
|
|
|
content: |
|
2021-11-22 20:53:18 +00:00
|
|
|
DEBUG=1
|
|
|
|
CACHE=diskcache
|
2021-12-25 17:21:55 +00:00
|
|
|
CACHE_SIZE=1073741824 # 1GiB
|
2021-12-05 15:49:40 +00:00
|
|
|
- path: /var/lib/cloud/scripts/per-boot/morss.sh
|
|
|
|
permissions: 744
|
|
|
|
content: |
|
|
|
|
#!/bin/sh
|
2022-01-08 15:10:51 +00:00
|
|
|
/usr/local/bin/morss-helper daemon
|
2021-11-21 21:38:26 +00:00
|
|
|
|
|
|
|
runcmd:
|
2021-12-25 10:02:27 +00:00
|
|
|
- source /etc/environment
|
2021-11-21 21:38:26 +00:00
|
|
|
- update-ca-certificates
|
2021-12-10 14:05:58 +00:00
|
|
|
- iptables -I INPUT 6 -m state --state NEW -p tcp --dport ${PORT:-8000} -j ACCEPT
|
2021-11-30 22:08:37 +00:00
|
|
|
- netfilter-persistent save
|
2021-12-10 14:05:58 +00:00
|
|
|
- pip install morss[full]
|
2021-11-21 21:38:26 +00:00
|
|
|
```
|
2021-11-21 20:57:06 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
## Run
|
|
|
|
|
|
|
|
morss will auto-detect what "mode" to use.
|
|
|
|
|
|
|
|
### Running on/as a server
|
|
|
|
|
|
|
|
Set up the server as indicated below, then visit:
|
2013-11-16 16:48:21 +00:00
|
|
|
|
2020-08-21 21:52:56 +00:00
|
|
|
```
|
2020-10-01 20:25:53 +00:00
|
|
|
http://PATH/TO/MORSS/[main.py/][:argwithoutvalue[:argwithvalue=value[...]]]/FEEDURL
|
|
|
|
```
|
2020-08-21 21:52:56 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
For example: `http://morss.example/:clip/https://twitter.com/pictuga`
|
2020-08-21 21:52:56 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
*(Brackets indicate optional text)*
|
2020-08-21 21:52:56 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
The `main.py` part is only needed if your server doesn't support the Apache
|
|
|
|
redirect rule set in the provided `.htaccess`.
|
2020-08-21 21:52:56 +00:00
|
|
|
|
2021-09-07 18:30:18 +00:00
|
|
|
Works like a charm with [Tiny Tiny RSS](https://tt-rss.org/), and most probably
|
|
|
|
other clients.
|
2020-08-21 21:52:56 +00:00
|
|
|
|
|
|
|
|
2021-10-31 16:15:08 +00:00
|
|
|
#### Using Docker
|
|
|
|
|
2021-12-05 19:28:03 +00:00
|
|
|
From docker hub
|
|
|
|
|
|
|
|
```shell
|
|
|
|
docker run -p 8000:8000 pictuga/morss
|
|
|
|
```
|
|
|
|
|
|
|
|
From source
|
2021-10-31 16:15:08 +00:00
|
|
|
|
|
|
|
```shell
|
|
|
|
docker run -p 8000:8000 morss
|
|
|
|
```
|
|
|
|
|
2022-12-13 21:07:21 +00:00
|
|
|
With docker-compose **(recommended)**
|
2020-08-21 21:52:56 +00:00
|
|
|
|
2021-10-31 16:15:08 +00:00
|
|
|
```shell
|
|
|
|
docker-compose up
|
|
|
|
```
|
2020-08-21 21:52:56 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
#### Using Gunicorn
|
|
|
|
|
|
|
|
```shell
|
|
|
|
gunicorn --preload morss
|
2020-08-21 21:52:56 +00:00
|
|
|
```
|
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
#### Using uWSGI
|
2013-11-16 16:48:21 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
Running this command should do:
|
2013-04-28 09:37:11 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
```shell
|
2021-10-19 20:19:59 +00:00
|
|
|
uwsgi --http :8000 --plugin python --wsgi-file main.py
|
2020-10-01 20:25:53 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
#### Using morss' internal HTTP server
|
|
|
|
|
|
|
|
Morss can run its own, **very basic**, HTTP server, meant for debugging mostly.
|
2021-10-19 20:19:59 +00:00
|
|
|
The latter should start when you run morss without any argument, on port 8000.
|
2020-10-01 20:25:53 +00:00
|
|
|
I'd highly recommend you to use gunicorn or something similar for better
|
|
|
|
performance.
|
|
|
|
|
|
|
|
```shell
|
|
|
|
morss
|
|
|
|
```
|
|
|
|
|
|
|
|
You can change the port using environment variables like this `PORT=9000 morss`.
|
2013-04-28 09:37:11 +00:00
|
|
|
|
2017-03-19 08:36:32 +00:00
|
|
|
#### Via mod_cgi/FastCGI with Apache/nginx
|
2014-05-21 10:09:50 +00:00
|
|
|
|
2015-08-29 10:45:36 +00:00
|
|
|
For this, you'll want to change a bit the architecture of the files, for example
|
|
|
|
into something like this.
|
2014-05-21 10:09:50 +00:00
|
|
|
|
2015-08-29 10:45:36 +00:00
|
|
|
```
|
|
|
|
/
|
|
|
|
├── cgi
|
|
|
|
│ │
|
|
|
|
│ ├── main.py
|
|
|
|
│ ├── morss
|
|
|
|
│ │ ├── __init__.py
|
|
|
|
│ │ ├── __main__.py
|
|
|
|
│ │ ├── morss.py
|
2017-03-09 01:21:26 +00:00
|
|
|
│ │ └── ...
|
2015-08-29 10:45:36 +00:00
|
|
|
│ │
|
|
|
|
│ ├── dateutil
|
2017-03-09 01:21:26 +00:00
|
|
|
│ └── ...
|
2015-08-29 10:45:36 +00:00
|
|
|
│
|
|
|
|
├── .htaccess
|
2017-03-09 01:21:26 +00:00
|
|
|
├── index.html
|
|
|
|
└── ...
|
2015-08-29 10:45:36 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
For this, you need to make sure your host allows python script execution. This
|
|
|
|
method uses HTTP calls to fetch the RSS feeds, which will be handled through
|
|
|
|
`mod_cgi` for example on Apache severs.
|
|
|
|
|
2021-12-24 17:03:55 +00:00
|
|
|
Please pay attention to `main.py` permissions for it to be executable. See below
|
|
|
|
some tips for the `.htaccess` file.
|
|
|
|
|
|
|
|
```htaccess
|
|
|
|
Options -Indexes
|
|
|
|
|
|
|
|
ErrorDocument 404 /cgi/main.py
|
|
|
|
|
|
|
|
# Turn debug on for all requests
|
|
|
|
SetEnv DEBUG 1
|
|
|
|
|
|
|
|
# Turn debug on for requests with :debug in the url
|
|
|
|
SetEnvIf Request_URI :debug DEBUG=1
|
|
|
|
|
|
|
|
<Files ~ "\.(py|pyc|db|log)$">
|
|
|
|
deny from all
|
|
|
|
</Files>
|
|
|
|
|
|
|
|
<Files main.py>
|
|
|
|
allow from all
|
|
|
|
AddHandler cgi-script .py
|
|
|
|
Options +ExecCGI
|
|
|
|
</Files>
|
|
|
|
```
|
2015-08-29 10:45:36 +00:00
|
|
|
|
2017-03-19 08:36:32 +00:00
|
|
|
### As a CLI application
|
2013-11-16 16:48:21 +00:00
|
|
|
|
2020-03-20 10:41:43 +00:00
|
|
|
Run:
|
2020-10-01 20:25:53 +00:00
|
|
|
|
2020-03-20 10:41:43 +00:00
|
|
|
```
|
2020-08-21 21:52:56 +00:00
|
|
|
morss [--argwithoutvalue] [--argwithvalue=value] [...] FEEDURL
|
2020-03-20 10:41:43 +00:00
|
|
|
```
|
2020-10-01 20:25:53 +00:00
|
|
|
|
2020-08-24 17:39:27 +00:00
|
|
|
For example: `morss --clip http://feeds.bbci.co.uk/news/rss.xml`
|
2020-03-20 10:41:43 +00:00
|
|
|
|
2013-11-16 16:48:21 +00:00
|
|
|
*(Brackets indicate optional text)*
|
|
|
|
|
2021-10-31 16:15:08 +00:00
|
|
|
If using Docker:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
docker run morss --clip http://feeds.bbci.co.uk/news/rss.xml
|
|
|
|
```
|
|
|
|
|
2017-03-19 08:36:32 +00:00
|
|
|
### As a newsreader hook
|
2013-04-04 15:43:30 +00:00
|
|
|
|
2015-08-29 10:45:36 +00:00
|
|
|
To use it, the newsreader [Liferea](http://lzone.de/liferea/) is required
|
|
|
|
(unless other newsreaders provide the same kind of feature), since custom
|
|
|
|
scripts can be run on top of the RSS feed, using its
|
|
|
|
[output](http://lzone.de/liferea/scraping.htm) as an RSS feed.
|
2013-04-04 15:43:30 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
To use this script, you have to enable "(Unix) command" in liferea feed
|
|
|
|
settings, and use the command:
|
|
|
|
|
2020-03-20 10:41:43 +00:00
|
|
|
```
|
2021-01-23 20:40:46 +00:00
|
|
|
morss [--argwithoutvalue] [--argwithvalue=value] [...] FEEDURL
|
2020-03-20 10:41:43 +00:00
|
|
|
```
|
2020-10-01 20:25:53 +00:00
|
|
|
|
2020-04-14 16:07:19 +00:00
|
|
|
For example: `morss http://feeds.bbci.co.uk/news/rss.xml`
|
2020-03-20 10:41:43 +00:00
|
|
|
|
2014-05-21 10:07:15 +00:00
|
|
|
*(Brackets indicate optional text)*
|
2013-04-04 15:43:30 +00:00
|
|
|
|
2017-03-19 08:36:32 +00:00
|
|
|
### As a python library
|
2014-05-21 10:14:26 +00:00
|
|
|
|
2014-05-24 17:03:05 +00:00
|
|
|
Quickly get a full-text feed:
|
2020-10-01 20:25:53 +00:00
|
|
|
|
2014-05-24 17:03:05 +00:00
|
|
|
```python
|
|
|
|
>>> import morss
|
2014-05-24 17:14:12 +00:00
|
|
|
>>> xml_string = morss.process('http://feeds.bbci.co.uk/news/rss.xml')
|
2014-05-24 17:03:05 +00:00
|
|
|
>>> xml_string[:50]
|
|
|
|
"<?xml version='1.0' encoding='UTF-8'?>\n<?xml-style"
|
|
|
|
```
|
|
|
|
|
2014-05-24 17:14:12 +00:00
|
|
|
Using cache and passing arguments:
|
2020-10-01 20:25:53 +00:00
|
|
|
|
2014-05-24 17:03:05 +00:00
|
|
|
```python
|
|
|
|
>>> import morss
|
|
|
|
>>> url = 'http://feeds.bbci.co.uk/news/rss.xml'
|
2023-06-25 23:30:47 +00:00
|
|
|
>>> cache = '/tmp/morss-cache' # diskcache cache location
|
2020-03-18 15:47:00 +00:00
|
|
|
>>> options = {'csv':True}
|
2014-05-24 17:03:05 +00:00
|
|
|
>>> xml_string = morss.process(url, cache, options)
|
|
|
|
>>> xml_string[:50]
|
|
|
|
'{"title": "BBC News - Home", "desc": "The latest s'
|
|
|
|
```
|
|
|
|
|
2015-08-29 10:45:36 +00:00
|
|
|
`morss.process` is actually a wrapper around simpler function. It's still
|
|
|
|
possible to call the simpler functions, to have more control on what's happening
|
|
|
|
under the hood.
|
2014-05-24 17:17:58 +00:00
|
|
|
|
2014-05-24 17:03:05 +00:00
|
|
|
Doing it step-by-step:
|
2020-10-01 20:25:53 +00:00
|
|
|
|
2014-05-21 10:46:48 +00:00
|
|
|
```python
|
2023-06-25 23:30:47 +00:00
|
|
|
import morss
|
2014-05-21 13:05:35 +00:00
|
|
|
|
2014-05-21 10:46:48 +00:00
|
|
|
url = 'http://newspaper.example/feed.xml'
|
2020-03-18 15:47:00 +00:00
|
|
|
options = morss.Options(csv=True) # arguments
|
2014-05-21 10:46:48 +00:00
|
|
|
|
2020-04-28 20:30:21 +00:00
|
|
|
url, rss = morss.FeedFetch(url, options) # this only grabs the RSS feed
|
2017-03-09 01:17:40 +00:00
|
|
|
rss = morss.FeedGather(rss, url, options) # this fills the feed and cleans it up
|
2014-05-21 10:46:48 +00:00
|
|
|
|
2020-04-27 16:12:14 +00:00
|
|
|
output = morss.FeedFormat(rss, options, 'unicode') # formats final feed
|
2014-05-21 10:46:48 +00:00
|
|
|
```
|
2014-05-21 10:14:26 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
## Arguments and settings
|
2013-04-04 15:43:30 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
### Arguments
|
2020-08-23 16:43:18 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
morss accepts some arguments, to lightly alter the output of morss. Arguments
|
2020-10-03 18:56:40 +00:00
|
|
|
may need to have a value (usually a string or a number). How to pass those
|
|
|
|
arguments to morss is explained in Run above.
|
2013-04-04 15:43:30 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
The list of arguments can be obtained by running `morss --help`
|
|
|
|
|
|
|
|
```
|
2021-09-18 14:16:34 +00:00
|
|
|
usage: morss [-h] [--post STRING] [--xpath XPATH]
|
|
|
|
[--format {rss,json,html,csv}] [--search STRING] [--clip]
|
2022-01-23 11:27:07 +00:00
|
|
|
[--indent] [--cache] [--force] [--proxy]
|
|
|
|
[--order {first,last,newest,oldest}] [--firstlink] [--resolve]
|
|
|
|
[--items XPATH] [--item_link XPATH] [--item_title XPATH]
|
2023-05-04 07:01:52 +00:00
|
|
|
[--item_content XPATH] [--item_time XPATH]
|
|
|
|
[--mode {xml,html,json}] [--nolink] [--noref] [--silent]
|
2020-10-01 20:25:53 +00:00
|
|
|
url
|
|
|
|
|
|
|
|
Get full-text RSS feeds
|
|
|
|
|
|
|
|
positional arguments:
|
|
|
|
url feed url
|
2020-09-30 21:59:55 +00:00
|
|
|
|
2022-01-23 11:27:07 +00:00
|
|
|
options:
|
2020-10-01 20:25:53 +00:00
|
|
|
-h, --help show this help message and exit
|
2021-09-08 18:43:21 +00:00
|
|
|
--post STRING POST request
|
2021-09-18 14:16:34 +00:00
|
|
|
--xpath XPATH xpath rule to manually detect the article
|
2020-10-01 20:25:53 +00:00
|
|
|
|
|
|
|
output:
|
|
|
|
--format {rss,json,html,csv}
|
|
|
|
output format
|
|
|
|
--search STRING does a basic case-sensitive search in the feed
|
|
|
|
--clip stick the full article content under the original feed
|
|
|
|
content (useful for twitter)
|
|
|
|
--indent returns indented XML or JSON, takes more place, but
|
|
|
|
human-readable
|
|
|
|
|
|
|
|
action:
|
|
|
|
--cache only take articles from the cache (ie. don't grab new
|
|
|
|
articles' content), so as to save time
|
|
|
|
--force force refetch the rss feed and articles
|
|
|
|
--proxy doesn't fill the articles
|
2022-01-23 11:27:07 +00:00
|
|
|
--order {first,last,newest,oldest}
|
|
|
|
order in which to process items (which are however NOT
|
|
|
|
sorted in the output)
|
2020-10-01 20:25:53 +00:00
|
|
|
--firstlink pull the first article mentioned in the description
|
|
|
|
instead of the default link
|
|
|
|
--resolve replace tracking links with direct links to articles
|
|
|
|
(not compatible with --proxy)
|
|
|
|
|
|
|
|
custom feeds:
|
|
|
|
--items XPATH (mandatory to activate the custom feeds function)
|
|
|
|
xpath rule to match all the RSS entries
|
|
|
|
--item_link XPATH xpath rule relative to items to point to the entry's
|
|
|
|
link
|
|
|
|
--item_title XPATH entry's title
|
|
|
|
--item_content XPATH entry's content
|
|
|
|
--item_time XPATH entry's date & time (accepts a wide range of time
|
|
|
|
formats)
|
2023-05-04 07:01:52 +00:00
|
|
|
--mode {xml,html,json}
|
|
|
|
parser to use for the custom feeds
|
2020-10-01 20:25:53 +00:00
|
|
|
|
|
|
|
misc:
|
|
|
|
--nolink drop links, but keeps links' inner text
|
|
|
|
--noref drop items' link
|
|
|
|
--silent don't output the final RSS (useless on its own, but
|
|
|
|
can be nice when debugging)
|
|
|
|
|
|
|
|
GNU AGPLv3 code
|
|
|
|
```
|
|
|
|
|
|
|
|
Further HTTP-only options:
|
|
|
|
|
|
|
|
- `callback=NAME`: for JSONP calls
|
|
|
|
- `cors`: allow Cross-origin resource sharing (allows XHR calls from other
|
|
|
|
servers)
|
|
|
|
- `txt`: changes the http content-type to txt (for faster "`view-source:`")
|
|
|
|
|
|
|
|
### Environment variables
|
|
|
|
|
|
|
|
To pass environment variables:
|
|
|
|
|
2021-10-19 20:19:59 +00:00
|
|
|
- Docker-cli: `docker run -p 8000:8000 morss --env KEY=value`
|
2020-10-01 20:25:53 +00:00
|
|
|
- docker-compose: add an `environment:` section in the .yml file
|
|
|
|
- Gunicorn/uWSGI/CLI: prepend `KEY=value` before the command
|
|
|
|
- Apache: via the `SetEnv` instruction (see sample `.htaccess` provided)
|
2021-12-24 10:44:56 +00:00
|
|
|
- cloud-init: in the `/etc/environment` file
|
2020-10-01 20:25:53 +00:00
|
|
|
|
|
|
|
Generic:
|
|
|
|
|
2020-10-03 18:56:40 +00:00
|
|
|
- `DEBUG=1`: to have some feedback from the script execution. Useful for
|
|
|
|
debugging.
|
2020-10-03 17:57:08 +00:00
|
|
|
- `IGNORE_SSL=1`: to ignore SSL certs when fetch feeds and articles
|
2020-10-03 20:22:20 +00:00
|
|
|
- `DELAY` (seconds) sets the browser cache delay, only for HTTP clients
|
|
|
|
- `TIMEOUT` (seconds) sets the HTTP timeout when fetching rss feeds and articles
|
2022-01-25 21:36:34 +00:00
|
|
|
- `DATA_PATH`: to set custom file location for the `www` folder
|
2013-04-04 15:43:30 +00:00
|
|
|
|
2015-08-29 10:45:36 +00:00
|
|
|
When parsing long feeds, with a lot of items (100+), morss might take a lot of
|
|
|
|
time to parse it, or might even run into a memory overflow on some shared
|
|
|
|
hosting plans (limits around 10Mb), in which case you might want to adjust the
|
2020-08-23 14:09:58 +00:00
|
|
|
below settings via environment variables.
|
2013-05-23 19:48:45 +00:00
|
|
|
|
2021-01-14 21:34:57 +00:00
|
|
|
Also, if the request takes too long to process, the http request might be
|
|
|
|
discarded. See relevant config for
|
|
|
|
[gunicorn](https://docs.gunicorn.org/en/stable/settings.html#timeout) or
|
|
|
|
[nginx](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout).
|
|
|
|
|
2020-10-03 20:22:20 +00:00
|
|
|
- `MAX_TIME` (seconds) sets the maximum amount of time spent *fetching*
|
|
|
|
articles, more time might be spent taking older articles from cache. `-1` for
|
|
|
|
unlimited.
|
2020-10-01 20:25:53 +00:00
|
|
|
- `MAX_ITEM` sets the maximum number of articles to fetch. `-1` for unlimited.
|
|
|
|
More articles will be taken from cache following the nexts settings.
|
2020-10-03 20:22:20 +00:00
|
|
|
- `LIM_TIME` (seconds) sets the maximum amount of time spent working on the feed
|
|
|
|
(whether or not it's already cached). Articles beyond that limit will be dropped
|
|
|
|
from the feed. `-1` for unlimited.
|
2020-10-01 20:25:53 +00:00
|
|
|
- `LIM_ITEM` sets the maximum number of article checked, limiting both the
|
|
|
|
number of articles fetched and taken from cache. Articles beyond that limit will
|
|
|
|
be dropped from the feed, even if they're cached. `-1` for unlimited.
|
2013-04-19 09:37:43 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
morss uses caching to make loading faster. There are 3 possible cache backends:
|
2014-01-09 19:34:12 +00:00
|
|
|
|
2020-10-01 20:25:53 +00:00
|
|
|
- `(nothing/default)`: a simple python in-memory dict-like object.
|
2021-09-11 19:36:14 +00:00
|
|
|
- `CACHE=redis`: Redis cache. Connection can be defined with the following
|
|
|
|
environment variables: `REDIS_HOST`, `REDIS_PORT`, `REDIS_DB`, `REDIS_PWD`
|
2021-11-08 20:57:43 +00:00
|
|
|
- `CACHE=diskcache`: disk-based cache. Target directory canbe defined with
|
2021-12-23 11:02:24 +00:00
|
|
|
`DISKCACHE_DIR`.
|
2020-10-01 20:25:53 +00:00
|
|
|
|
|
|
|
To limit the size of the cache:
|
|
|
|
|
|
|
|
- `CACHE_SIZE` sets the target number of items in the cache (further items will
|
2020-10-03 17:55:57 +00:00
|
|
|
be deleted but the cache might be temporarily bigger than that). Defaults to 1k
|
2021-11-08 20:57:43 +00:00
|
|
|
entries. NB. When using `diskcache`, this is the cache max size in Bytes.
|
2020-10-03 20:22:20 +00:00
|
|
|
- `CACHE_LIFESPAN` (seconds) sets how often the cache must be trimmed (i.e. cut
|
|
|
|
down to the number of items set in `CACHE_SIZE`). Defaults to 1min.
|
2014-01-09 19:34:12 +00:00
|
|
|
|
2021-12-24 10:44:24 +00:00
|
|
|
Gunicorn also accepts command line arguments via the `GUNICORN_CMD_ARGS`
|
|
|
|
environment variable.
|
|
|
|
|
2017-03-19 08:36:32 +00:00
|
|
|
### Content matching
|
2013-04-19 09:37:43 +00:00
|
|
|
|
2017-03-01 05:25:59 +00:00
|
|
|
The content of articles is grabbed with our own readability fork. This means
|
2015-08-29 10:45:36 +00:00
|
|
|
that most of the time the right content is matched. However sometimes it fails,
|
|
|
|
therefore some tweaking is required. Most of the time, what has to be done is to
|
2020-10-01 20:25:53 +00:00
|
|
|
add some "rules" in the main script file in `readabilite.py` (not in morss).
|
2013-03-29 19:05:53 +00:00
|
|
|
|
2015-08-29 10:45:36 +00:00
|
|
|
Most of the time when hardly nothing is matched, it means that the main content
|
|
|
|
of the article is made of images, videos, pictures, etc., which readability
|
|
|
|
doesn't detect. Also, readability has some trouble to match content of very
|
|
|
|
small articles.
|
2013-04-04 16:31:26 +00:00
|
|
|
|
2015-08-29 10:45:36 +00:00
|
|
|
morss will also try to figure out whether the full content is already in place
|
|
|
|
(for those websites which understood the whole point of RSS feeds). However this
|
|
|
|
detection is very simple, and only works if the actual content is put in the
|
|
|
|
"content" section in the feed and not in the "summary" section.
|