Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

130
Vistas
How can I get data from another website's html elements in javascript?

I am trying to make a script that will compile statistics of my TikTok profile on my WordPress site. TikTok ironically sucks at giving you data about your profile, in my case I can't find a reliable way to check the total views I have on my profile from the native analytics page.

So I figured I would write a script that would take my TikTok page, scan through the html, find each page element that displays the view count on each post thumbnail, and add the value within that element to an array. The write a function that takes care of the math from there.

I thought that would be fairly easy, but I am a victim of the Dunning-Kruger effect as a freshman in Software Engineering.

From what I've looked at the answer seems to lay in jQuery. I have written this so far.

var views= []
 jQuery.get("https://www.tiktok.com/@triplicata.html",function() {
   //the view count element seems to change on different occasions but the element seems to always be "== $0"
   jQuery.each("$0",function(){ 
     var temp = jQuery.text();
     views.push(temp);
   });
 });

When I try to run it in a tester I check the F12 Console and it says something around the lines of:

Access to XMLHttpRequest at 'https://www.tiktok.com/@triplicata.html' from origin 'https://fiddle.jshell.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I can't even test the rest of the code cause I seem to be cut off at the gate just trying to get the HTML in the first place. I don't really know much about jQuery but everything seems to be correct from what I've seen.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I don't know why you would do this, ever heard of viewsource?

<script src="https://cdn.jsdelivr.net/gh/Parking-Master/viewsource/vs.js"></script>
<script>
  console.log(getSource('https://example.com'));
</script>

You can't access another website's source code for a good reason. And the jquery get() method is only for JSON files.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda