当前位置 huginn huginn 正文 下一篇:

Huginn 浅尝——通过 Rss 看小说

传说有两个乌鸦,名为 Huginn 和 Muninn,它们被视为奥丁的左肩右臂。奥丁在黎明时送出 Huginn 和 Muninn ,它们飞到世界各地,然后在晚餐时间回来,告诉奥丁它们看到和听到的一切,奥丁则赐予它们食物作为报酬。—— Huginn 命名的由来

Huginn

Huginn

不记得什么时候 Star 的了,只记得当时看 README 很厉害的样子,类似一个个人监控助理类的软件。大概就是一个加强版的 IFTTT,可以监控各种信息,然后通知你。比起即刻App可订制化更高点,需要的一些基本知识也更多些:Linux基本操作、CSS基本使用、Xpath基本使用、JSON最基本知识……当然比起自己写爬虫还是简单些。

春节折腾了好久,主要麻烦在搭建,配置要求也比较高,至少要 0.5GB RAM + 0.5GB swap,但是在 VPS 上装了很多次总是有各种各样的问题(其实就是配置不够),还是用 docker 省事,有域名的再随便开个 Nginx 转发就好了。

Install Script

docker 安装脚本

# Show commands executed
set -x

# Setup swap file so it works better on lower memory VMs
fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile   none    swap    sw    0   0" >> /etc/fstab

sysctl vm.swappiness=10
echo "vm.swappiness=10" >> /etc/sysctl.conf

useradd -s/bin/bash -m huginn

# Run the huginn docker container on port 3000, map the MySQL data to the host machine in /home/huginn/mysql-data
# So the data is persisted across runs/updates (handy)
mkdir /tmp/docker-huginn/
cd /tmp/docker-huginn/
docker run -d -p 3000:3000 -v /home/huginn/mysql-data:/var/lib/mysql cantino/huginn

Nginx 配置

server {
        listen 0.0.0.0:80;
        listen [::]:80 ipv6only=on;
        server_name huginn.yourdomain.com;;
        server_tokens off;

        access_log  /var/log/nginx/huginn-access.log;
        error_log   /var/log/nginx/huginn-error.log;

        add_header Strict-Transport-Security max-age=63072000;
        add_header X-Frame-Options DENY;
        add_header X-Content-Type-Options nosniff;

        gzip on;

        rewrite_log on;

        # use the application's 500.html page
        error_page 500 502 503 504 /500.html;

        # allow clients to upload large files (if necessary)
        client_max_body_size 4G;

        location / {
                proxy_pass        http://XXX.XXX.XXX.XXX:3000;
                proxy_redirect    off;

                proxy_set_header  Host                $http_host;
                proxy_set_header  X-Real-IP           $remote_addr;
                proxy_set_header  X-Forwarded-Ssl     on;
                proxy_set_header  X-Forwarded-For     $proxy_add_x_forwarded_for;
                proxy_set_header  X-Forwarded-Proto   $scheme;
                proxy_set_header  X-Frame-Options     SAMEORIGIN;

                client_max_body_size        100m;
                client_body_buffer_size     128k;

                proxy_buffer_size           4k;
                proxy_buffers               4 32k;
                proxy_busy_buffers_size     64k;
                proxy_temp_file_write_size  64k;
        }

        add_header Strict-Transport-Security max-age=2592000;
}

利用 Huginn 为小说生成 Rss

抓取的笔趣阁的,手机版格式简单点,更好设置 Web Agent 一些。

My Scenario

终于没有迷人的小广告了,不过用 Feedly 有些延时。

Twitter,商品价格监控什么的有空在研究吧。

尝鲜

虽然自用第三方平台上总是有各种限制,但是作为尝鲜还是很不错的选择。
如果你对 Huginn 有兴趣,不妨可以先到我在樱花 docker 开的 Huginn 上试试。
当然熟人我也可以在自用的上面给你多开一个帐号。

Reference

  • Huginn Wiki
  • Huginn中文指南:搭建自己的iFTTT
  • Huginn: 烧录RSS的神器
  • 让所有网页变成RSS —— Huginn
  • Automated deployment on DigitalOcean with Fodor.xyz

原文链接:https://www.jianshu.com/p/35b6d06530fe

发表回复

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部