Browse Source

added Cambio 21

Pablo 1 week ago
parent
commit
64d0bf6e29
6 changed files with 33 additions and 1 deletions
  1. 2 0
      .env.example
  2. 1 1
      package.json
  3. 2 0
      src/config.ts
  4. 2 0
      src/index.ts
  5. 4 0
      src/portales/cambio21/definition.yml
  6. 22 0
      src/portales/cambio21/handler.ts

+ 2 - 0
.env.example

@@ -17,6 +17,7 @@ MASTODON_DB_DATABASE = "mastodon"
 24HORAS = "https://www.24horas.cl/"
 ADNRADIO = "https://www.adnradio.cl/"
 BIOBIOCHILE = "https://www.biobiochile.cl/"
+CAMBIO21 = "https://cambio21.cl/"
 CHILECULTURA = "https://chilecultura.gob.cl/events/"
 CIPER = "https://www.ciperchile.cl/actualidad/"
 CODEXVERDE = "https://codexverde.cl/"
@@ -43,6 +44,7 @@ THECLINIC = "https://www.theclinic.cl/lo-ultimo/"
 MASTODON_KEY_24HORAS = ""
 MASTODON_KEY_ADNRADIO = ""
 MASTODON_KEY_BIOBIOCHILE = ""
+MASTODON_KEY_CAMBIO21 = ""
 MASTODON_KEY_CHILECULTURA = ""
 MASTODON_KEY_CIPER = ""
 MASTODON_KEY_CNNCHILE = ""

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "bot-noticias",
-  "version": "0.0.24",
+  "version": "0.0.25",
   "description": "Bot que busca noticias y las replica en mastodon.cl",
   "main": "dist/index.js",
   "scripts": {

+ 2 - 0
src/config.ts

@@ -18,6 +18,7 @@ const config = {
   HORAS24: process.env["24HORAS"] ?? "https://www.24horas.cl/",
   ADNRADIO: process.env.ADNRADIO ?? "https://www.adnradio.cl/",
   BIOBIOCHILE: process.env.BIOBIOCHILE ?? "https://www.biobiochile.cl/",
+  CAMBIO21: process.env.CAMBIO21 ?? "https://cambio21.cl/",
   CHILECULTURA: process.env.CHILECULTURA ?? "https://chilecultura.gob.cl/",
   CIPER: process.env.CIPER ?? "https://www.ciperchile.cl/actualidad/",
   CODEXVERDE: process.env.CODEXVERDE ?? "https://codexverde.cl/",
@@ -45,6 +46,7 @@ const config = {
   MASTODON_KEY_24HORAS: process.env.MASTODON_KEY_24HORAS ?? "",
   MASTODON_KEY_ADNRADIO: process.env.MASTODON_KEY_ADNRADIO ?? "",
   MASTODON_KEY_BIOBIOCHILE: process.env.MASTODON_KEY_BIOBIOCHILE ?? "",
+  MASTODON_KEY_CAMBIO21: process.env.MASTODON_KEY_CAMBIO21 ?? "",
   MASTODON_KEY_CHILECULTURA: process.env.MASTODON_KEY_CHILECULTURA ?? "",
   MASTODON_KEY_CIPER: process.env.MASTODON_KEY_CIPER ?? "",
   MASTODON_KEY_CODEXVERDE: process.env.MASTODON_KEY_CODEXVERDE ?? "",

+ 2 - 0
src/index.ts

@@ -5,6 +5,7 @@ import config from "./config";
 import { handler as horas24 } from "./portales/24horas/handler";
 import { handler as adnradio } from "./portales/adnradio/handler";
 import { handler as biobiochile } from "./portales/biobiochile/handler";
+import { handler as cambio21 } from "./portales/cambio21/handler";
 import { handler as chilecultura } from "./portales/chilecultura/handler";
 import { handler as ciper } from "./portales/ciper/handler";
 import { handler as cnnchile } from "./portales/cnnchile/handler";
@@ -48,6 +49,7 @@ const portalsHandlers = {
   "24horas": horas24,
   "adnradio": adnradio,
   "biobiochile": biobiochile,
+  "cambio21": cambio21,
   "chilecultura": chilecultura,
   "ciper": ciper,
   "cnnchile": cnnchile,

+ 4 - 0
src/portales/cambio21/definition.yml

@@ -0,0 +1,4 @@
+cambio21:
+  handler: ./src/portales/cambio21/handler.handler
+  events: 
+    - schedule: rate(1 hour)

+ 22 - 0
src/portales/cambio21/handler.ts

@@ -0,0 +1,22 @@
+import { type Handler } from "aws-lambda";
+
+import config from "../../config";
+import Portal from "../portal";
+import ScraperMethods from "../../enums/scraper-methods";
+
+const name = "Cambio21";
+
+export const handler: Handler = new Portal(
+  name,
+  config.MASTODON_KEY_CAMBIO21,
+  {
+    url: config.CAMBIO21,
+    articlesSelector: ".news-post.image-post, .news-post.video-post",
+    titleSelector: "h2 a",
+    linkSelector: "h2 a",
+    imageSelector: "img",
+    scraperMethod: ScraperMethods.AXIOS,
+    maxArticles: 20,
+    hashtags: ["Cambio21", "Noticias"]
+  }
+).getHandler();