T
T
TaiLo2020-09-29 23:35:26
Python
TaiLo, 2020-09-29 23:35:26

How to parse shadow dom in python?

I suffered for a long time and thought why there is no text in the source code, but then I went through safari and saw shadow contents there.
Is it possible to parse it somehow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2020-09-30
@rPman

Don't bother with parsing, open the website in a browser, wait for all scripts to load and execute, and grab the result directly from the DOM document.
The simplest thing is to create a 'web browser' application in your favorite programming language for which there are webkit libraries (for example, on .net it is to add a WebBrowser control to the form and set the address, and then inject your javascript code on the onload event or any of your choice, in java, I made such an application in 20 lines, half of which is support for resizing the window).
Of course, you can use all sorts of Silenium or other automated testing tools, but this is an overcomplication, I tried both.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question