Browse Source

added 24Horas

Pablo 1 tuần trước cách đây
mục cha
commit
5f0b3dc146

+ 2 - 0
.env.example

@@ -14,6 +14,7 @@ MASTODON_DB_PASSWORD = "password"
 MASTODON_DB_DATABASE = "mastodon"
 
 # PORTALES
+24HORAS = "https://www.24horas.cl/"
 ADNRADIO = "https://www.adnradio.cl/"
 BIOBIOCHILE = "https://www.biobiochile.cl/"
 CHILECULTURA = "https://chilecultura.gob.cl/events/"
@@ -36,6 +37,7 @@ TARREO = "https://www.tarreo.com/noticias/"
 THECLINIC = "https://www.theclinic.cl/lo-ultimo/"
 
 # KEYS
+MASTODON_KEY_24HORAS = ""
 MASTODON_KEY_ADNRADIO = ""
 MASTODON_KEY_BIOBIOCHILE = ""
 MASTODON_KEY_CHILECULTURA = ""

+ 1 - 1
package.json

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

+ 2 - 0
src/config.ts

@@ -15,6 +15,7 @@ const config = {
   MASTODON_DB_PASSWORD: process.env.MASTODON_DB_PASSWORD,
   MASTODON_DB_DATABASE: process.env.MASTODON_DB_DATABASE,
   // PORTALES
+  HORAS24: process.env["24HORAS"] ?? "https://www.24horas.cl/",
   ADNRADIO: process.env.ADNRADIO ?? "https://www.adnradio.cl/",
   BIOBIOCHILE: process.env.BIOBIOCHILE ?? "https://www.biobiochile.cl/",
   CHILECULTURA: process.env.CHILECULTURA ?? "https://chilecultura.gob.cl/",
@@ -38,6 +39,7 @@ const config = {
   TARREO: process.env.TARREO ?? "https://www.tarreo.com/noticias/",
   THECLINIC: process.env.THECLINIC ?? "https://www.theclinic.cl/lo-ultimo/",
   // KEYS
+  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_CHILECULTURA: process.env.MASTODON_KEY_CHILECULTURA ?? "",

+ 3 - 1
src/index.ts

@@ -2,6 +2,7 @@ import { type Context, type Handler } from "aws-lambda";
 
 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 chilecultura } from "./portales/chilecultura/handler";
@@ -13,9 +14,9 @@ import { handler as df } from "./portales/df/handler";
 import { handler as elciudadano } from "./portales/elciudadano/handler";
 import { handler as eldesconcierto } from "./portales/eldesconcierto/handler";
 import { handler as elmostrador } from "./portales/elmostrador/handler";
+import { handler as emol } from "./portales/emol/handler";
 import { handler as fastcheck } from "./portales/fastcheck/handler";
 // import { handler as glaciareschilenos } from "./portales/glaciareschilenos/handler";
-import { handler as emol } from "./portales/emol/handler";
 import { handler as interferencia } from "./portales/interferencia/handler";
 import { handler as laderasur } from "./portales/laderasur/handler";
 import { handler as lanacion } from "./portales/lanacion/handler";
@@ -41,6 +42,7 @@ const context: Context = {
 };
 
 const portalsHandlers = {
+  "24horas": horas24,
   "adnradio": adnradio,
   "biobiochile": biobiochile,
   "chilecultura": chilecultura,

+ 4 - 0
src/portales/24horas/definition.yml

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

+ 24 - 0
src/portales/24horas/handler.ts

@@ -0,0 +1,24 @@
+import { type Handler } from "aws-lambda";
+
+import config from "../../config";
+import Portal from "../portal";
+import ScraperMethods from "../../enums/scraper-methods";
+
+const name = "24 Horas";
+
+export const handler: Handler = new Portal(
+  name,
+  config.MASTODON_KEY_24HORAS,
+  {
+    url: config["HORAS24"],
+    articlesSelector: "article.swiper-slide, div.list-item",
+    titleSelector: "h3.tit a",
+    linkSelector: "h3.tit a",
+    contentSelector: "p.baj",
+    imageSelector: "img[data-src], img[src]",
+    linkPrefix: "https://www.24horas.cl",
+    scraperMethod: ScraperMethods.AXIOS,
+    maxArticles: 20,
+    hashtags: ["24Horas", "Noticias"]
+  }
+).getHandler();

+ 1 - 1
src/portales/portal.ts

@@ -66,7 +66,7 @@ export default class Portal {
         }
 
         // To avoid publiposts (I'm lookint at you La Tercera >:-|)
-        if (article.link.includes("publirreportajes")) {
+        if (article.link.includes("publirreportajes") || article.link.includes("publireportajes")) {
           continue;
         }