Monday, 2 May 2022

Python & Selenium: How to get Elements in DevTools with CDP (Chrome DevTools Protocol)

I'd like to get all source code in Elements with Chrome DevTools.

enter image description here

Although I tried the following code, these values are not match with the above code.

body = driver.execute_cdp_cmd("DOM.getOuterHTML", {"backendNodeId": 1})
print(body)

Is it possible to get all source code with CDP? How can I get all source code with CDP?

I know the another way to scrape the source code. But I'd like to know how to get the source code in Elements in DevTools. (F12)



from Python & Selenium: How to get Elements in DevTools with CDP (Chrome DevTools Protocol)

No comments:

Post a Comment