django-feed-reader:一个RSSAtomJSONFeed阅读和Django存储库

  • Y3_181293
    了解作者
  • 143.8KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-07 03:56
    上传日期
Django Feed阅读器 这是一个简单的Django模块,可让您订阅RSS(和其他)提要。 这个应用程式没有使用者介面,只会读取并储存资讯提供,供您视需要使用。 该应用程序建立在FeedParser库的顶部,以提供Feed管理,存储,调度等。 产品特点 消费RSS,Atom和JSONFeed提要。 解析器随意输入以尝试容纳简单错误。 将尝试绕过Feed的Cloudflare保护 支持机箱(播客)发现 根据更新频率自动安排Feed 安装 django-feed-reader用Python 3编写,并支持Django 2.2+ pip install django-feed-reader 将feeds添加到您的INSTALLED_APPS 在settings.py设置一些值,以便您的供稿阅读器向服务器客气地宣布自己: 将FEEDS_USER_AGENT设置为服务的名称和(可选版本),例如"ExampleFeeder/1.2" 将FEEDS_SERVER设置为服务的首选网址,以便供稿主机可以根据需要找到您,例如https://example.com 设置一种定期刷新提
django-feed-reader-master.zip
内容介绍
# Django Feed Reader This is a simple Django module to allow you subscribe to RSS (and other) feeds. This app has no UI, it just reads and stores the feeds for you to use as you see fit. This app builds on top of the FeedParser library to provide feed management, storage, scheduling etc. ## Features * Consumes RSS, Atom and JSONFeed feeds. * Parses feeds liberally to try and accomodate simple errors. * Will attempt to bypass Cloudflare protection of feeds * Supports enclosure (podcast) discovery * Automatic feed scheduling based on frequency of updates ## Installation `django-feed-reader` is written in Python 3 and supports Django 2.2+ 1. `pip install django-feed-reader` 2. Add `feeds` to your `INSTALLED_APPS` 3. Setup some values in `settings.py` so that your feed reader politely announces itself to servers: * Set `FEEDS_USER_AGENT` to the name and (optionally version) of your service e.g. `"ExampleFeeder/1.2"` * Set `FEEDS_SERVER` to preferred web address of your service so that feed hosts can locate you if required e.g. `https://example.com` 4. Setup a mechanism to periodically refresh the feeds (see below) ## Basic Models A feed is represented by a `Source` object which has (among other things) a `feed_url`. `Source`s have `Posts` which contain the content. `Posts` may have `Enclosure`s which is what podcasts use to send their audio. The app does not download enclosures, if you want to do that you will need to it in your project using the url provided. A full description of the models and their fields is coming soon (probably). In the mean time, why not read `models.py`, it's all obvious stuff. ## Refreshing feeds To conserve resources with large feed lists, the app will adjust how often it polls feeds based on how often they are updated. The fastest it will poll a feed is every hour. The slowest it will poll is every 24 hours. Feeds that don't get updated are polled progressively more slowly until the 24 hour limit is reached. When a feed changes, its polling frequency increases. You will need to decided how and when to run the poller. When the poller runs, it checks all feeds that are currently due. The ideal frequency to run it is every 5 - 10 minutes. ### Polling with cron. Set up a job that calls `python manage.py refreshfeeds` on your desired schedule. Be careful to ensure you're running out of the correct directory and with the correct python environment. ### Polling with celery Create a new celery task and schedule in your app (see the celery documentation for details). Your `tasks.py` should look something like this: ```python from celery import shared_task from feeds.utils import update_feeds @shared_task def get_those_feeds(): # the number is the max number of feeds to poll in one go update_feeds(30) ``` ## Tracking subscribers and read/unread state of feeds The app does not (currently) track the read/unread state of posts within a feed. That will need doing in your project according to your needs. The app assumes that each feed only has one subscriber that is the project itself. If your project can allow personal subscriptions for individual users, you can let the app know on per feed basis how many subscribers it has by settings `num_subs` on a `Source` object. The app will then report this via the user agent to the feed source for analytics purposes. ### Dealing with Cloudflare Depending on where you run your server, you may run into problems with Cloudflare's web captcha. Plenty of sites out there set up their Cloudflare to have default security on their RSS feed and this can block server-side RSS readers. It's a huge pain and affects lots of self-hosted RSS readers. Seriously, Google it. `django-feed-reader` will do it's utmost to get these feeds anyway through the judicious use of public proxy servers, but is haphazard and you cannot rely on the scheduling of such feeds. Feeds blocked by Cloudflare will have the `is_cloudflare` flag set on their `Source` and will update on a best-efforts basis.
评论
    相关推荐
    • django_rundirect:移至https
      django_rundirect 这是一个简单的Django命令,可在加载了Django设置和环境设置的情况下运行自定义Python脚本(或一行Python代码)。 因此,您无需在脚本中放入任何与Django设置相关的代码。 要安装此软件包 pip ...
    • Django 小例子
      NULL 博文链接:https://zzh.iteye.com/blog/370298
    • Django样板
      $~ git clone https://github.com/ibnuhalimm/django-boilerplate.git < your> 将virtualenv安装到您的项目中 $~ virtualenv 去你的项目 $~ cd 激活virtualenv $~ source bin/activate 安装所有依赖项 $~ pip...
    • Django Model
      NULL 博文链接:https://booby325.iteye.com/blog/1715169
    • django实例
      NULL 博文链接:https://yanshaozhi.iteye.com/blog/1835370
    • django_rest_tutorial:从https学习Django REST框架
      django_rest_tutorial 从学习django REST框架
    • lfs - django
      NULL 博文链接:https://lsqwzz.iteye.com/blog/1387958
    • django_app:https
      构建Project是为了使人们对Django框架更加熟悉。 这个项目的想法是用票务系统构建一个问题跟踪器。 人们可以轻松地为问题投票。 投票的想法是简单地显示应该首先修复哪些错误。 还应将功能与支付系统连接。 该项目的...
    • Django中间件
      NULL 博文链接:https://summerbell.iteye.com/blog/364461
    • Django的书
      NULL 博文链接:https://boyfuxin.iteye.com/blog/772696