From fe19c2ae27d2b6990d1184aca8561077ad210d3c Mon Sep 17 00:00:00 2001 From: ZacharyDavidSaunders Date: Mon, 28 Jan 2019 20:10:18 -0800 Subject: [PATCH] Fixing !FreeBook trigger in response to PaktPub updating their site --- lib/sage/responders/triggers.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sage/responders/triggers.ex b/lib/sage/responders/triggers.ex index e14a24b..23b09a9 100644 --- a/lib/sage/responders/triggers.ex +++ b/lib/sage/responders/triggers.ex @@ -78,12 +78,12 @@ defmodule Sage.Responders.Triggers do {:ok, resp} = :httpc.request(:get, {'https://www.packtpub.com/packt/offers/free-learning', []}, [], [body_format: :binary]) {{_, 200, 'OK'}, _headers, body} = resp - title = Floki.find(body, ".dotd-title h2") + title = Floki.find(body, ".product__title") |> Floki.text() |> String.trim() - description = Floki.find(body, ".dotd-main-book-summary div:nth-of-type(3)") + author = Floki.find(body, ".product__author") |> Floki.text() |> String.trim() - result = "Today's free book is: \n" <> title <> "\n" <> description <> "\nhttps://www.packtpub.com/packt/offers/free-learning" + result = "Today's free book is: \n" <> title <> "\nBy:" <> author <> "\nhttps://www.packtpub.com/packt/offers/free-learning" end end