Getting a variable from a HTML?

Posts 110 of 10 · Page 1 of 1
Getting a variable from a HTML?
If you look at any youtube playlist page's source, there is a variable call "ytInitialData" in the built in script section. I was wondering how would I get that data with js? I'm looking at cheerio and request tools for js but all the tutorials seem to teach only scraping html section and not deal with the script section.
Quote Originally Posted by Zenitram View Post
I think your question is more suitable for this section, buddy:
https://www.mpgh.net/forum/14-programming/
section is dead and web development doesn't really considered as programming
I didn't look at the source code but you could use document.getElementById
Quote Originally Posted by Allura View Post
I didn't look at the source code but you could use document.getElementById
That wont work because that only get the html element and wont touch the js
Quote Originally Posted by w4ssup View Post


That wont work because that only get the html element and wont touch the js
Oh soz. I mis-read. I didn't see that part where you said the data is within the script.
every object is part of the window Object, with a full interpreted page u can fetch the data from there, for example with a Greesemonkey or similour Browser Addon, it shouldlnt be a problem
Quote Originally Posted by MikeRohsoft View Post
every object is part of the window Object, with a full interpreted page u can fetch the data from there, for example with a Greesemonkey or similour Browser Addon, it shouldlnt be a problem
I'm im trying to fetch the data with a js and not a browser addon
but what js? an cscript interpreted js? nodejs? Greesemonkey?
so far i can see that, there is just a variable which i can just call it in the javascript console, i need more info from where u want to fetch it

Anyways, the Variable is not initialized if u download the page by an external program, it will be generated on runtime by the engine. You need to do it with a Browser Addon, or C# which can access a browser, or u must yt believe, u r a browser, like anserewing the necessary requests
Does it work with selenium and headless browser?
Posts 110 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?