How do I locate a specific line of code from a website and then display it on an html file using javascript? -


so i'm programming website , want display current fan count copied directly soundcloud account. here coding i'm using right now: (if helps find code i'm trying locate. here link soundcloud. i'm trying locate "follower" number count. https://soundcloud.com/gammatoid-official)

<p id="text"></p> <script src="https://soundcloud.com/gammatoid-official" type="text/html"> </script> <script> var fansel = document.getelementsbyclassname("infostats__value sc-font-tabular-light").innerhtml; document.getelementbyid("text").innerhtml = fansel; </script> 

it keeps giving me "undefined" result can't figure out needs changed.

the way trying won't work, because can't load data other websites without getting explicit permission them through cross-origin resource sharing (cors).

you should use soundcloud's api this. if scrape data website, code need change whenever change website, , hassle maintain, while api should stay relatively stable.

you can request follower count of given user using /users endpoint. give json object has, among other properties, follower_count.


Comments