Explorar o código

added Las Voz de los que Sobran

Pablo hai 1 semana
pai
achega
30ea0e52a4

+ 2 - 0
.env.example

@@ -33,6 +33,7 @@ FASTCHECK = "https://www.fastcheck.cl/"
 GLACIARESCHILENOS = "https://www.glaciareschilenos.org/articulos/"
 INTERFERENCIA = "https://interferencia.cl/"
 LADERASUR = "https://laderasur.com/articulos-2/"
+LAVOZDELOSQUESOBRAN = "https://lavozdelosquesobran.cl/"
 LATERCERA = "https://www.latercera.com/canal/nacional/"
 METEORED = "https://www.meteored.cl/"
 RESUMEN = "https://resumen.cl/"
@@ -60,6 +61,7 @@ MASTODON_KEY_FASTCHECK = ""
 MASTODON_KEY_GLACIARESCHILENOS = ""
 MASTODON_KEY_INTERFERENCIA = ""
 MASTODON_KEY_LADERASUR = ""
+MASTODON_KEY_LAVOZDELOSQUESOBRAN = ""
 MASTODON_KEY_LANACION = ""
 MASTODON_KEY_LATERCERA = ""
 MASTODON_KEY_METEORED = ""

+ 1 - 1
package.json

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

+ 2 - 0
src/config.ts

@@ -35,6 +35,7 @@ const config = {
   GLACIARESCHILENOS: process.env.GLACIARESCHILENOS ?? "https://www.glaciareschilenos.org/articulos/",
   INTERFERENCIA: process.env.INTERFERENCIA ?? "https://interferencia.cl/",
   LADERASUR: process.env.LADERASUR ?? "https://laderasur.com/",
+  LAVOZDELOSQUESOBRAN: process.env.LAVOZDELOSQUESOBRAN ?? "https://lavozdelosquesobran.cl/",
   LANACION: process.env.LANACION ?? "https://www.lanacion.cl/",
   LATERCERA: process.env.LATERCERA ?? "https://www.latercera.com/canal/nacional/",
   METEORED: process.env.METEORED ?? "https://www.meteored.cl/",
@@ -63,6 +64,7 @@ const config = {
   MASTODON_KEY_GLACIARESCHILENOS: process.env.MASTODON_KEY_GLACIARESCHILENOS ?? "",
   MASTODON_KEY_INTERFERENCIA: process.env.MASTODON_KEY_INTERFERENCIA ?? "",
   MASTODON_KEY_LADERASUR: process.env.MASTODON_KEY_LADERASUR ?? "",
+  MASTODON_KEY_LAVOZDELOSQUESOBRAN: process.env.MASTODON_KEY_LAVOZDELOSQUESOBRAN ?? "",
   MASTODON_KEY_LANACION: process.env.MASTODON_KEY_LANACION ?? "",
   MASTODON_KEY_LATERCERA: process.env.MASTODON_KEY_LATERCERA ?? "",
   MASTODON_KEY_METEORED: process.env.MASTODON_KEY_METEORED ?? "",

+ 2 - 1
src/enums/props.ts

@@ -1,7 +1,8 @@
 enum Props {
   TEXT = "text",
   LINK = "href",
-  IMAGE = "src"
+  IMAGE = "src",
+  DATA_IMAGE = "data-src"
 };
 
 export default Props

+ 2 - 0
src/index.ts

@@ -22,6 +22,7 @@ import { handler as fastcheck } from "./portales/fastcheck/handler";
 // import { handler as glaciareschilenos } from "./portales/glaciareschilenos/handler";
 import { handler as interferencia } from "./portales/interferencia/handler";
 import { handler as laderasur } from "./portales/laderasur/handler";
+import { handler as lavozdelosquesobran } from "./portales/lavozdelosquesobran/handler";
 import { handler as lanacion } from "./portales/lanacion/handler";
 import { handler as latercera } from "./portales/latercera/handler";
 import { handler as meteored } from "./portales/meteored/handler";
@@ -66,6 +67,7 @@ const portalsHandlers = {
   // "glaciareschilenos": glaciareschilenos,
   "interferencia": interferencia,
   "laderasur": laderasur,
+  "lavozdelosquesobran": lavozdelosquesobran,
   "lanacion": lanacion,
   "latercera": latercera,
   "meteored": meteored,

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

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

+ 23 - 0
src/portales/lavozdelosquesobran/handler.ts

@@ -0,0 +1,23 @@
+import { type Handler } from "aws-lambda";
+
+import config from "../../config";
+import Portal from "../portal";
+import ScraperMethods from "../../enums/scraper-methods";
+
+const name = "La Voz de los Que Sobran";
+
+export const handler: Handler = new Portal(
+  name,
+  config.MASTODON_KEY_LAVOZDELOSQUESOBRAN,
+  {
+    url: config.LAVOZDELOSQUESOBRAN,
+    articlesSelector: ".lvqs-hero-cnn-main, .lvqs-hero-cnn-sub, .lvqs-card",
+    titleSelector: "h2 a, h3 a, .lvqs-card-title a",
+    linkSelector: "h2 a, h3 a, .lvqs-card-title a",
+    contentSelector: ".lvqs-hero-cnn-excerpt, .lvqs-card-excerpt",
+    imageSelector: "img[data-src], img",
+    scraperMethod: ScraperMethods.AXIOS,
+    maxArticles: 20,
+    hashtags: ["LaVozDeLosQueSobran", "Noticias"]
+  }
+).getHandler();

+ 7 - 0
src/utils/scraper-articles.ts

@@ -67,6 +67,13 @@ export default class ScraperArticles {
     const selector = this._options.imageSelector ?? "";
     let imgUrl = selector !== "" ? this.getProperty(article, selector, Props.IMAGE) : "";
 
+    if (selector !== "") {
+      const dataSrcUrl = this.getProperty(article, selector, Props.DATA_IMAGE);
+      if (dataSrcUrl !== "") {
+        imgUrl = dataSrcUrl;
+      }
+    }
+
     if (imgUrl !== "") {
       if (!this.isValidUrl(imgUrl) && this._options.imagePrefix) {
         imgUrl = this._options.imagePrefix + imgUrl.trim();