Get HTML Source Code from Browser

I try to use javascript "getElementsByTagName("BODY")" functions to get HTML source code from open Webpage. The function works in console, but it doesn’t work in Keyboard Maestro. After getting this HTML I want to beatify it (like this site http://jsbeautifier.org do). Maybe you know some ways to beatify it through Keyboard Maestro. Thank you!

P.S. I checked other javascripts from forum and javascript action seems to function.

Try this:

document.getElementsByTagName("BODY")[0].innerHTML

or outerHTML, depending on what you want.

2 Likes

Hey Mykola,

There are a variety of pretty-print utilities available.

tidy can be installed via MacPorts (and I assume Homebrew).

Balthisar Tidy is scriptable.

http://www.balthisar.com/blog/introducing-balthisar-tidy-for-work/

Chances are that whatever solution you decide upon will have a learning-curve, so be prepared.

-Chris

1 Like