• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

325
Views
¿Cómo obtener el valor del atributo de una etiqueta de intervalo con Cheerio en Javascript?

Estoy tratando de obtener un porcentaje de cambio de precio de una acción de Google Finance con Cheerio en Javascript. El siguiente código no funcionó, mientras que la etiqueta span muestra el valor en su atributo "aria-label". ¿Alguien puede ayudar a solucionar el problema? ¡Gracias por cualquier consejo!

 function test() { var url = 'https://www.google.com/finance/quote/VZ:nyse'; var res = UrlFetchApp.fetch(url, { muteHttpExceptions: true }).getContentText(); var $ = Cheerio.load(res); // Succesfully retrieved the price. var price = $('div[class="YMlKec fxKbKc"]').first().text(); console.log(price) // But couldn't figure out how to pull the price change percent. // The following code pulled out some results, but didn't include "Down by 3.55%", which is the price change that I'm looking for. What's missing? var changePercent = $('span[jsname="Fe7oBc"]').toArray().map(el => $(el).attr('aria-label')); console.log(changePercent) }

ingrese la descripción de la imagen aquí

almost 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error