Jump to content
Macro Express Forums

How to save the html in the browser.


tommytx
 Share

Recommended Posts

Once the html page from the web loads into the browser, its a simple matter to Ctrl A then do a clipboard save, but I need the entire html not just the text.

Is there an easy way to save the html to hard drive?

Thanks in advance for any ideas.

The following will put the entire HTML code for a webpage* into variable T1:

If Window Title "Internet Explorer" is on top
 Variable Set String %T2% "IE"
End If
If Window Title "Google Chrome" is on top
 Variable Set String %T2% "GC"
End If
If Variable %T2% <> "GC"
 If Variable %T2% <> "IE"
Text Type: <ALT>v
Delay 0.25 Seconds
Text Type: o
Wait For Window Title: "Source"
 Else
Text Type: <ALT>vc
Wait For Window Title: "Notepad"
 End If
Else
 Text Type: <CONTROL>u
 Delay 0.25 Seconds
 Wait For Window Title: "Google Chrome"
End If
Text Type: <CONTROL>a
Clipboard Copy
Variable Set String %T1% from Clipboard

<IFOTH:03:2:Internet Explorer><TVAR2:02:01:IE><ENDIF><IFOTH:03:2:Google Chrome><TVAR2:02:01:GC><ENDIF><IFVAR2:1:02:2:GC><IFVAR2:1:02:2:IE><TEXTTYPE:<ALT>v><DELAY:.25><TEXTTYPE:o><WAITWIN2:000010:000000:Source><ELSE><TEXTTYPE:<ALT>vc><WAITWIN2:000010:000000:Notepad><ENDIF><ELSE><TEXTTYPE:<CONTROL>u><DELAY:.25><WAITWIN2:000010:000000:Google Chrome><ENDIF><TEXTTYPE:<CONTROL>a><CLIPC><TVAR2:01:03:>

 

If you don't need it in a variable, and just want to save it as a .txt file on your hard drive, you would adjust the code like this:

If Window Title "Internet Explorer" is on top
 Variable Set String %T2% "IE"
End If
If Window Title "Google Chrome" is on top
 Variable Set String %T2% "GC"
End If
If Variable %T2% <> "GC"
 If Variable %T2% <> "IE"
Text Type: <ALT>v
Delay 0.25 Seconds
Text Type: o
Wait For Window Title: "Source"
 Else
Text Type: <ALT>vc
Wait For Window Title: "Notepad"
 End If
Else
 Text Type: <CONTROL>u
 Delay 0.25 Seconds
 Wait For Window Title: "Google Chrome"
End If
Text Type: <CONTROL>a
Clipboard Copy
Clipboard Save Text: "HTML Save Test"

<IFOTH:03:2:Internet Explorer><TVAR2:02:01:IE><ENDIF><IFOTH:03:2:Google Chrome><TVAR2:02:01:GC><ENDIF><IFVAR2:1:02:2:GC><IFVAR2:1:02:2:IE><TEXTTYPE:<ALT>v><DELAY:.25><TEXTTYPE:o><WAITWIN2:000010:000000:Source><ELSE><TEXTTYPE:<ALT>vc><WAITWIN2:000010:000000:Notepad><ENDIF><ELSE><TEXTTYPE:<CONTROL>u><DELAY:.25><WAITWIN2:000010:000000:Google Chrome><ENDIF><TEXTTYPE:<CONTROL>a><CLIPC><CLIPST2:0:C:\Users\Steven\Documents\Macros\Macro Test Files\HTML Save Test>

 

*Note that this code was tested and works on IE 7.x, Firefox 3.0.5, Opera 9.61, and Google Chrome 1.0.154.36

Depending on your computer's speed, delays may need to be adjusted/added.

 

Because I tested this for 4 different browsers, the code is kind of long. If you know you will only be using one specific

browser, you could shorten this code dramatically.

Link to comment
Share on other sites

Here is a short macro to do what you want in Firefox. It would be easy to modify the code for other browsers. It's best to set the scope of the macro to window specific, e.g., "- Mozilla Firefox" etc.

 

// Hotkey to view Page Source...

Text Type: <CONTROL>u

Wait for Window Title: Source of:

// Copy all to clipboard...

Text Type: <CONTROL>a

Text Type: <CONTROL>c

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...