Is there a way to get the actual HTML of a current active tab in Chrome? Some websites use the position on the page to induce an AJAX call to expand the page further. So working with a URL only won't cut it. Actually grabbing the current HTML is what I'm after.

At the moment, I can ask Chrome to open a new tab with the source of the tab, but that's a bit cumbersome. The libraries haven't shown me anything with regards to grabbing current active HTML.

Can I somehow use AppleScript to get the current active tab HTML?


1 Answer 1


Here is one way to grab the HTML of the active tab of the front window of Google Chrome using AppleScript:

tell application "Google Chrome" to set sourceHTML to ¬
    execute front window's active tab javascript "document.documentElement.outerHTML"

Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.

  • Looks like you got a winner. Mine was similar, again, with making a new tab. This one is cleaner. Excellent
    – Rich_F
    Apr 5, 2019 at 16:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .