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

313
Views
Matriz vacía al intentar raspar la página principal de YouTube con Node.js

así que estoy jugando con request y cheerio npm y parece que no puedo encontrar una solución, ¿por qué sigue dándome matrices vacías? Usé el mismo código cuando raspé reddit y funcionó de maravilla, pero cuando lo uso en YouTube o en cualquier otra página no funciona.

 var request = require('request'), cheerio = require('cheerio'), fs = require('fs'), urls = []; request('https://www.youtube.com/', function(err,resp,body) { if(!err && resp.statusCode == 200) { var $ = cheerio.load(body); $('a.yt-simple-endpoint style-scope ytd-grid-video-renderer', 'primary').each(function() { var url = $(this); urls.push(url); });

Y este es mi código de reddit (funciona bien)

 var request = require('request'), cheerio = require('cheerio'), fs = require('fs'), urls = []; request('http://www.reddit.com/', function(err,resp,body) { if(!err && resp.statusCode == 200) { var $ = cheerio.load(body); $('a.title', '#siteTable').each(function() { var url = $(this).attr('href'); if(url.indexOf('imgur.com')!= -1) { urls.push(url); } }); Output Example: [ 'http://i.imgur.com/WVrmZ9j.gifv', 'http://i.imgur.com/T0BchYC.gifv', 'http://imgur.com/u59lzux' ]
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

El HTML que carga Cheerio para YouTube es diferente.

Haz res.send($.html()); para verificar la estructura HTML y orientarla en consecuencia.

over 4 years ago · Santiago Trujillo Report
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!