Bläddra i källkod

Merge branch 'develop' of Mastodon/bots into main

Pablo Yaksic 1 vecka sedan
förälder
incheckning
78b44f3cb6
6 ändrade filer med 34 tillägg och 2 borttagningar
  1. 2 0
      .env.example
  2. 1 1
      package.json
  3. 2 0
      src/config.ts
  4. 3 1
      src/index.ts
  5. 4 0
      src/portales/cnnchile/definition.yml
  6. 22 0
      src/portales/cnnchile/handler.ts

+ 2 - 0
.env.example

@@ -20,6 +20,7 @@ BIOBIOCHILE = "https://www.biobiochile.cl/"
 CHILECULTURA = "https://chilecultura.gob.cl/events/"
 CIPER = "https://www.ciperchile.cl/actualidad/"
 CODEXVERDE = "https://codexverde.cl/"
+CNNCHILE = "https://www.cnnchile.com/"
 COOPERATIVA = "https://cooperativa.cl/noticias/site/cache/nroedic/todas/"
 DF = "https://www.df.cl/ultimasnoticias"
 ELCIUDADANO = "https://www.elciudadano.com/"
@@ -44,6 +45,7 @@ MASTODON_KEY_ADNRADIO = ""
 MASTODON_KEY_BIOBIOCHILE = ""
 MASTODON_KEY_CHILECULTURA = ""
 MASTODON_KEY_CIPER = ""
+MASTODON_KEY_CNNCHILE = ""
 MASTODON_KEY_CODEXVERDE = ""
 MASTODON_KET_COOPERATIVA = ""
 MASTODON_KEY_DF = ""

+ 1 - 1
package.json

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

+ 2 - 0
src/config.ts

@@ -23,6 +23,7 @@ const config = {
   CODEXVERDE: process.env.CODEXVERDE ?? "https://codexverde.cl/",
   CONTRAPODER: process.env.CONTRAPODER ?? "https://contrapoderchile.cl/category/portada/",
   COOPERATIVA: process.env.COOPERATIVA ?? "https://www.cooperativa.cl/",
+  CNNCHILE: process.env.CNNCHILE ?? "https://www.cnnchile.com/",
   DF: process.env.DF ?? "https://www.df.cl/ultimasnoticias",
   ELCIUDADANO: process.env.ELCIUDADANO ?? "https://www.elciudadano.com/chile/",
   ELDESCONCIERTO: process.env.ELDESCONCIERTO ?? "https://eldesconcierto.cl",
@@ -47,6 +48,7 @@ const config = {
   MASTODON_KEY_CHILECULTURA: process.env.MASTODON_KEY_CHILECULTURA ?? "",
   MASTODON_KEY_CIPER: process.env.MASTODON_KEY_CIPER ?? "",
   MASTODON_KEY_CODEXVERDE: process.env.MASTODON_KEY_CODEXVERDE ?? "",
+  MASTODON_KEY_CNNCHILE: process.env.MASTODON_KEY_CNNCHILE ?? "",
   MASTODON_KEY_CONTRAPODER: process.env.MASTODON_KEY_CONTRAPODER ?? "",
   MASTODON_KEY_COOPERATIVA: process.env.MASTODON_KEY_COOPERATIVA ?? "",
   MASTODON_KEY_DF: process.env.MASTODON_KEY_DF ?? "",

+ 3 - 1
src/index.ts

@@ -7,6 +7,7 @@ import { handler as adnradio } from "./portales/adnradio/handler";
 import { handler as biobiochile } from "./portales/biobiochile/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";
 import { handler as codexverde } from "./portales/codexverde/handler";
 import { handler as contrapoder } from "./portales/contrapoder/handler";
 import { handler as cooperativa } from "./portales/cooperativa/handler";
@@ -24,7 +25,7 @@ import { handler as lanacion } from "./portales/lanacion/handler";
 import { handler as latercera } from "./portales/latercera/handler";
 import { handler as meteored } from "./portales/meteored/handler";
 // import { handler as metrodesantiago } from "./portales/metrodesantiago/handler";
-import { handler as resumen } from "./portales/resumen/handler";
+//import { handler as resumen } from "./portales/resumen/handler";
 import { handler as tarreo } from "./portales/tarreo/handler";
 import { handler as theclinic } from "./portales/theclinic/handler";
 
@@ -49,6 +50,7 @@ const portalsHandlers = {
   "biobiochile": biobiochile,
   "chilecultura": chilecultura,
   "ciper": ciper,
+  "cnnchile": cnnchile,
   "codexverde": codexverde,
   "contrapoder": contrapoder,
   "cooperativa": cooperativa,

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

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

+ 22 - 0
src/portales/cnnchile/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 = "CNN Chile";
+
+export const handler: Handler = new Portal(
+  name,
+  config.MASTODON_KEY_CNNCHILE,
+  {
+    url: config.CNNCHILE,
+    articlesSelector: "article.main-card",
+    titleSelector: ".main-card__title a",
+    linkSelector: ".main-card__title a",
+    imageSelector: "img.main-card__image",
+    scraperMethod: ScraperMethods.PUPPETEER,
+    maxArticles: 20,
+    hashtags: ["CNNChile", "Noticias"]
+  }
+).getHandler();