Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

329
Views
No capturado (en promesa) TypeError: s.createConnection no es una función en n.register.c.connect

Actualmente estoy tratando de explotar una fuente RSS para obtener los últimos artículos de un sitio web.

Lo que estoy haciendo es almacenar estos datos en una base de datos MySQL. Lo hago con Javascript, para tomar información de la fuente RSS.

Cuando alojo el script en mi servidor, ya no funciona.

Para el contexto de la programación, en local, usé XAMPP, con un host local. Luego, hago una compilación de paquetes, el script se adjunta a una página HTML, de modo que puedo llamarlo simplemente cargando la página web.

Recibí el error del título:
Mensaje del error: "No detectado (en promesa) TypeError: s.createConnection no es una función en n.register.c.connect

Aquí está el código:

 let Parser = require('rss-parser'); let parser = new Parser(); (async () => { // Connecting to database const mysql = require('mysql'); const connection = mysql.createConnection({ host: 'localhost', user: 'root', password: '', database: 'dataarticles' }); connection.connect((err) => { if (err) throw err; console.log('Connected!'); }); let feed = await parser.parseURL('http://feedrinse.com/services/rinse/?rinsedurl=235e4f5244e1eeb21ce05fc3d4d68cc0'); //== Some console.log to check // console.log(feed.items[0]['content:encoded']); //== Some console.log to check // console.log(feed.items[0].title + "\n" // + feed.items[0].link + "\n" // + feed.items[0].contentSnippet + "\n" // + feed.items[0].pubDate); // As the feed doesn't provide the minia of article, I take the first image in the content of the test, by searching it let firstPos = feed.items[0]['content:encoded'].search("https://droidsoft.fr/wp-content/uploads/"); let SecondPos = feed.items[0]['content:encoded'].search('alt="'); let image = feed.items[0]['content:encoded'].substring(firstPos, SecondPos - 2); let pubDate = feed.items[0].pubDate.substring(5, 16); //== Some console.log to check // console.log(image); // console.log(pubDate); // We take first item (items[0]) as it's the latest feed. This script is triggered only when there is a new element, so there shouldn't be // any problem of duplication connection.query('INSERT INTO `dataarticles` (`Titre`, `URL`, `Description`, `Image`, `date`) VALUES ("' + feed.items[0].title + '", "' + feed.items[0].link + '", "' + feed.items[0].contentSnippet + '", "' + image + '", "' + pubDate + '")', (err, rows) => { // if (err) throw err; console.log(rows); }); })();
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!