Jump to content

How to "Save as..." with IE with "Save as type" = Text File *.txt


bbocker
 Share

Recommended Posts

Hi,

Does anyone know if there is a way to use the IE "Save as..." feature and save the webpage as a text file (Text File *.txt) without using the Send() commands?

There MUST be a way to do this with the IE library but I have only seen examples of getting the .html or the .mht web archive and have had no luck figuring this out myself.

Thanks for any help!

Link to comment
Share on other sites

Hi,

Like Juvigy suggested you can check out InetGet which downloads the file directly and if you want the interface you will have to create your own or find one on the forum for example.

If you really want to use the IE Save As dialog you could try to get DoDownloadFile from shdocvw.dll to work, I got the function to work but it will crash AutoIt.

If you get it to work please make sure to post the result here.

_DoDownloadFile('http://www.autoitscript.com/site/wp-content/themes/TheCorporation/images/logo.png')

; Works, as in triggers the Save As window, but then it crashes AutoIt (DLLCall return type perhaps?)
Func _DoDownloadFile($sURL)
    DllCall('ole32.dll', 'int', "CoInitialize", "uint", 0)
    If @error Then Return SetError(1, 0, 0)
    Local $mbsFile = _WinAPI_WideCharToMultiByte($sURL, 65001)
    DllCall('shdocvw.dll', 'str', 'DoFileDownload', 'wstr', $mbsFile)
    If @error Then Return SetError(2, 0, 0)
    Return SetError(0, 0, 1)
EndFunc   ;==>_DoDownloadFile
Edited by Robjong
Link to comment
Share on other sites

Robjong,

Thanks for the help. The thing is this: I've used INetGet quite a bit and it's great for most of the things I need to do. This particular problem, however, is a little different because the text I get when using InetGet is different than the text I get when I use "Save as...". The text from INetGet in this case is missing the list of results you see in the browser. However, if you "Save as..." into a text file the results are there.

I also tried wget but it has exactly the same problem as INetGet - it saves html and text, but the results are missing, and the results are the part I need. But I can get the results even if I use Firefox, as long as I use "Save Page As" and then just dump it as a text file - the results are there!

Obviously there is some difference in the way INetGet and wget works and the way the "Save Page As text file" function works, but I have no idea. I just need the results that are produced by the latter, and it would be great if it could be set up to do it in the background so the user can continue working on the machine doing other things.

Link to comment
Share on other sites

Sounds like it's HTML(?) that is generated by Javascript, you could try the _IE* functions.

#include <IE.au3>

$sURL = "http://goole.com"
$sFile = "file.html"

$oIE = _IECreate($sURL) ; open page, waits  until page is done loading...
$sHTML = _IEDocReadHTML($oIE) ; get the generated HTML
FileWrite($sFile, $sHTML) ; save HTML to file
_IEQuit($oIE) ; close IE

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...