Js2Py 'document is not defined' and I don't need 'document' at all
I scraped a server-side dynamically-obfuscated JS script from a main page and wanted to get some specific data from it (by evaluating some of the obfuscated script expressions). Although there are lots of occurrences of document and similar references to DOM, the part I'm interested in is not DOM dependent. So is there any way to ignore document is not defined or any other workaround on it?
Thanks!
You have to write minimal implementations of the objects and functions called by your target code and make sure your code runs first. I did it by creating a context, running my code, and then each html code block separately. This way it could fail on ad code while still allowing me process the bits of the code I'm interested in, pulling the results from the context afterwards. DOM manipulation can be a real pain if you need it though.
Please, can you provide a short example? I don't get your point. Thanks :)
If you would please provide some example code, I can provide an example of how it can be executed.
If you would please provide some example code, I can provide an example of how it can be executed.
Okay @worstperson , so this code is server-side dynamically obfuscated so I cannot reduce it since I would end up ignoring essential parts for data evaluation.
Ctrl+F and search for var q = h[bo('0x149')](['.'], j)[bo('0xf9')](''). I would like Python to evaluate and get the value of j after executing this line and save it into a str (String). Once done, the script can be stopped with no problem. The process per se of getting j is not DOM dependent at all, but obviously you can see lots of occurrences of symbols inside DOM.
I finally ended up using Jsdom in node.js to scrape the needed data.
@ElJaviLuki How did you solve it with Jsdom and nodejs ? I'm trying to figuring out which versions work. Thanks.