Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda