What is Huginn?
Here are some of the things that you can do with Huginn:
- Track the weather and get an email when it's going to rain (or snow) tomorrow ("Don't forget your umbrella!")
- List terms that you care about and receive emails when their occurrence on Twitter changes. (For example, want to know when something interesting has happened in the world of Machine Learning? Huginn will watch the term "machine learning" on Twitter and tell you when there is a spike in discussion.)
- Watch for air travel or shopping deals
- Follow your project names on Twitter and get updates when people mention them
- Scrape websites and receive emails when they change
- Connect to Adioso, HipChat, Basecamp, Growl, FTP, IMAP, Jabber, JIRA, MQTT, nextbus, Pushbullet, Pushover, RSS, Bash, Slack, StubHub, translation APIs, Twilio, Twitter, Wunderground, and Weibo, to name a few.
- Send digest emails with things that you care about at specific times during the day
- Track counts of high frequency events and send an SMS within moments when they spike, such as the term "san francisco emergency"
- Send and receive WebHooks
- Run custom JavaScript or CoffeeScript functions
- Track your location over time
- Create Amazon Mechanical Turk workflows as the inputs, or outputs, of agents (the Amazon Turk Agent is called the "HumanTaskAgent"). For example: "Once a day, ask 5 people for a funny cat photo; send the results to 5 more people to be rated; send the top-rated photo to 5 people for a funny caption; send to 5 final people to rate for funniest caption; finally, post the best captioned photo on my blog."
Join us!
Examples
Getting Started
Docker
Local Installation
- Run
git remote add upstream https://github.com/cantino/huginn.git
to add the main repository as a remote for your fork. - Copy
.env.example
to.env
(cp .env.example .env
) and edit.env
, at least updating theAPP_SECRET_TOKEN
variable. - Run
bundle
to install dependencies - Run
bundle exec rake db:create
,bundle exec rake db:migrate
, and thenbundle exec rake db:seed
to create a development MySQL database with some example Agents. - Run
bundle exec foreman start
, visit http://localhost:3000/, and login with the username ofadmin
and the password ofpassword
. - Setup some Agents!
- Read the wiki for usage examples and to get started making new Agents.
- Periodically run
git fetch upstream
and thengit checkout master && git merge upstream/master
to merge in the newest version of Huginn.
development
Rails environment, which is what you just setup. You can view them at http://localhost:3000/letter_opener. If you'd like to send real emails via SMTP when playing with Huginn locally, set SEND_EMAIL_IN_DEVELOPMENT
to true
in your .env
file.Nitrous Quickstart
Run > Start Huginn
and access your site via Preview > 3000
.Develop
- Install PhantomJS 2.1.1 or greater:
- Using Node Package Manager:
npm install phantomjs
- Using Homebrew on OSX
brew install phantomjs
- Using Node Package Manager:
- Run all specs with
bundle exec rspec
- Run a specific spec with
bundle exec rspec path/to/specific/test_spec.rb
. - Read more about rspec for rails here.
Deployment
Heroku
Manual installation on any server
Optional Setup
Setup for private development
Enable the WeatherAgent
api_key: your-key
in your seeded WeatherAgent.Disable SSL
config/initializers/devise.rb
and modify the line containing config.rememberable_options = { :secure => true }
. You will also need to edit config/environments/production.rb
and modify the value of config.force_ssl。
huginn|全网数据监控与通知工具—安装教程
今天发现了一个特别棒的工具—huginn,很实用,应用范围很广,确实是网络工具库中的神器。它可以监控网络上的一切资源,并将这些资源按照你的需要发送给你。实现这一功能只需要简单的配置就可以了。列举一下,huginn 主要的应用场景和功能。
1 跟没有 RSS 的网站定制 RSS 种子
2 监控知乎、微博、贴吧等平台指定的信息,一旦监控到信息,邮件通知你本人
3 监控各大购物平台商品信息,一旦发现折扣信息,邮件通知你
4 支持各种形式的发送和接收 WebHooks。
Huginn 就是私有的 IFTTT,自定义程度非常高,只要你思路开阔,想法够野一定能发挥出巨大的价值。
Huginn 安装
Huginn 的安装方法有很多种,我推荐一种,就是通过 docker 安装。原因很简单,安装快,而且这本身就是 docker 的主要应用场景和优势所在。如果是常规安装方式,需要安装依赖包、ruby 环境、数据库、nginx、huginn 及各种配置;但是 docker 就只需要下载 docker 镜像,运行 huginn 容器就可以了。
1 安装 docker
建议最低配置为 1G 内存、1 核 CPU。推荐使用 vultr 的基础款云服务器,自带一键安装 docker 功能。均采用千兆带宽、SSD 硬盘,稳定性有保障,按小时计费,随用随停,且支持支付宝付款。
Centos7 安装 docker 命令如下:
注:安装 docker 要求系统内核版本高于 3.0,基本上只能安装在 KVM 架构的 vps 上。
2 运行 huginn 容器
注:重启容器会导致数据丢失,请勿轻易应用到生产环境。
Huginn 界面
部署成功后访问 IP+3000 端口,出现界面,点击登录,默认账号密码是 admin/password.登录成功。
Huginn 使用介绍-以 website agent 采集网页为例
简单通过一个例子介绍下 huginn 的使用方法。监控 v2ex 首页第一个帖子,首页第一个帖子变化时,发送邮件通知。
1 新建一个 agent,负责每隔一分钟采集 v2ex 第一个帖子的标题,配置如下。点击 agents->new agent .
type 选择 website agent,表示从 web 站点采集数据;
name 是这个 agent 的名称
schedule 表示多久采集一次,本次设置的是每分钟一次
其他的暂时不用管,重要的是配置 option,即从 v2ex 采集第一个帖子的规则。
需要配置采集地址 url,即 v2ex 首页的网址;v2ex 第一个帖子的 css 定位,可以通过 f12 查看帖子的 xpath,但是获取的 xpath 经常有问题,推荐通过 selectorgadget chrome 扩展去获取定位;再配置获取的内容,我是获取的文字内容,填 normalize-space(.)即可.
最后点击“dry run” 测试一下是否可以获取到内容,下图所示即成功。点击 save,保存该 agent.
运行几分钟后,可以看到每分钟都能获取到新的 v2ex 帖子。
使用邮件通知 email agent
通过以上 v2ex agent 实现了每隔一分钟检测一次首页第一个帖子。然后再尝试一下将 v2ex agent 中的内容通过邮件发布。
需要另外新建一个 agent,type 选择 Email Agent,sources 选择我们之前创建的 v2ex agent,options 中填邮件内容,我们通过{{title}}引入了 v2ex agent 中的 title 字段。这样 v2ex agent 每次检测到内容更新,就会触发 email agent,将更新的内容通过邮件发送到本人。
另外,还需要配置邮件发送server接收相关内容。
首先要配置stmp 服务器。然后将 stmp 配置信息写到 huginn 容器的环境变量中去。所以需要用以下方式启动 huginn 容器:
其次,配置接收邮件人。
点击界面右上角的 account,将默认的邮箱 admin@example.com,改为接收邮箱号,邮件配置就完成了.