Get the html of the javascript-rendered page (after interacting with it)

前端 未结 4 415
感情败类
感情败类 2021-01-30 14:16

I would like to be able to save the state of the html page after I\'ve interacted with it.

Say I click a checkbox, or the javascript set the values of various elements.<

4条回答
  •  青春惊慌失措
    2021-01-30 14:23

    In Chrome (and apparently Firefox), there is a special copy() method that will copy the rendered content to the clipboard. Then you can do whatever you want by pasting it to your preferred text editor.

    https://developers.google.com/chrome-developer-tools/docs/commandline-api#copyobject

    Console Example:

    copy(document.body.innerHTML);
    

    Note: I noticed Chrome reports undefined after the method is run, however, it seems to execute correctly and the right content is in the clipboard.

提交回复
热议问题