Browse Source

added ciper

Pablo Barrera Yaksic 2 months ago
parent
commit
63601bf9f1

+ 3 - 1
.env.example

@@ -7,7 +7,8 @@ MASTODON_STREAMING_URL = "wss://<mastodon-domain>/api/v1/streaming"
 MASTODON_ACCESS_TOKEN = "<access-token>"
 IMG_PLACEHOLDER = "https://placehold.co/600x400"
 
-CHILECULTURA = "https://chilecultura.gob.cl/events/",
+CHILECULTURA = "https://chilecultura.gob.cl/events/"
+CIPER = "https://www.ciperchile.cl/actualidad/"
 DF = "https://www.df.cl/ultimasnoticias"
 ELCIUDADANO = "https://www.elciudadano.com/"
 ELDESCONCIERTO = "https://eldesconcierto.cl"
@@ -22,6 +23,7 @@ THECLINIC = "https://www.theclinic.cl/lo-ultimo/"
 
 # KEYS
 MASTODON_KEY_CHILECULTURA = ""
+MASTODON_KEY_CIPER = ""
 MASTODON_KEY_DF = ""
 MASTODON_KEY_ELCIUDADANO = ""
 MASTODON_KEY_ELDESCONCIERTO = ""

+ 2 - 0
src/config.ts

@@ -10,6 +10,7 @@ const config = {
   IMG_PLACEHOLDER: process.env.IMG_PLACEHOLDER ?? "https://placehold.co/600x400",
   // PORTALES
   CHILECULTURA: process.env.CHILECULTURA ?? "https://chilecultura.gob.cl/events/",
+  CIPER: process.env.CIPER ?? "https://www.ciperchile.cl/actualidad/",
   DF: process.env.DF ?? "https://www.df.cl/ultimasnoticias",
   ELCIUDADANO: process.env.ELCIUDADANO ?? "https://www.elciudadano.com/",
   ELDESCONCIERTO: process.env.ELDESCONCIERTO ?? "https://eldesconcierto.cl",
@@ -23,6 +24,7 @@ const config = {
   THECLINIC: process.env.THECLINIC ?? "https://www.theclinic.cl/lo-ultimo/",
   // KEYS
   MASTODON_KEY_CHILECULTURA: process.env.MASTODON_KEY_CHILECULTURA ?? "",
+  MASTODON_KEY_CIPER: process.env.MASTODON_KEY_CIPER?? "",
   MASTODON_KEY_DF: process.env.MASTODON_KEY_DF ?? "",
   MASTODON_KEY_ELCIUDADANO: process.env.MASTODON_KEY_ELCIUDADANO ?? "",
   MASTODON_KEY_ELDESCONCIERTO: process.env.MASTODON_KEY_ELDESCONCIERTO ?? "",

+ 2 - 0
src/index.ts

@@ -3,6 +3,7 @@ import { type Context, type Handler } from "aws-lambda";
 import config from "./config";
 
 import { handler as chilecultura } from "./portales/chilecultura/handler";
+import { handler as ciper } from "./portales/ciper/handler";
 import { handler as df } from "./portales/df/handler";
 import { handler as elciudadano } from "./portales/elciudadano/handler";
 import { handler as eldesconcierto } from "./portales/eldesconcierto/handler";
@@ -31,6 +32,7 @@ const context: Context = {
 
 const portalsHandlers = {
   "chilecultura": chilecultura,
+  "ciper": ciper,
   "df": df,
   "elciudadano": elciudadano,
   "eldesconcierto": eldesconcierto,

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

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

+ 21 - 0
src/portales/ciper/handler.ts

@@ -0,0 +1,21 @@
+import { type Handler } from "aws-lambda";
+
+import config from "../../config";
+import Portal from "../portal";
+import ScraperMethods from "../../enums/scraper-methods";
+
+const name = `CIPER Chile`;
+
+export const handler: Handler = new Portal(
+  name, 
+  config.MASTODON_KEY_CIPER,
+  {
+    url: config.CIPER,
+    articlesSelector: "section.section-featured article",
+    titleSelector: ".article-big-text__title, article:nth-child(1) > h3:nth-child(4)",
+    linkSelector: "a.alticle-link:nth-child(2), article:nth-child(1) > h3:nth-child(4) > a:nth-child(1)",
+    scraperMethod: ScraperMethods.AXIOS,
+    hashtags: ["CIPERChile", "Actualidad", "Artículo", "Investigación"],
+    cacheExpiration: 60 * 60 * 24 * 30, // 30 días
+  }
+).getHandler();

+ 1 - 1
src/portales/fastcheck/handler.ts

@@ -17,6 +17,6 @@ export const handler: Handler = new Portal(
     linkSelector: "header h1 a",
     scraperMethod: ScraperMethods.AXIOS,
     hashtags: ["FastCheck", "Artículo", "Noticias"],
-    cacheExpiration: 60 * 60 * 24 * 30, // 30 dís
+    cacheExpiration: 60 * 60 * 24 * 30, // 30 días
   }
 ).getHandler();