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

131
Views
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 answers
Answer question

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 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!