Sign in to follow this  
Followers 0
Sleeping Dragon

Saving a webpage to specified directory

12 posts in this topic

Hello everyone out there. This is my first experience using autoit so forgive me if the questions I ask aren't right. Also, I am a graphic/web designer by trade and writing code has proven to be my nemesis. At any rate allow me to move along. The company I work for needs to have certain pages that display real time data saved at certain points in the day to a specific directory. I have been able to open internet explorer to the correct url and open the save as window to the correct directory. I cannot figure out how to have autoit type a file name to save the document as. I am trying to use the current date as the file name. I have included the date.au3 file that came with the program when it was installed. Here is the code I am wishing to use can anyone help me trouble shoot it.

-----------------------------------------------------------------------------------------------------

#include <Date.au3>

;Run and open internet explorer to the site needed and saving.

;Run IE

Run("C:\Program Files\Internet Explorer\iexplore.exe http://www.ourwebsitepage.html")

;We wait for the webpage here

WinWaitActive("http://www.ourwebsitepage.html - Microsoft Internet Explorer")

Sleep(5000)

;Save it

Send("!f")

Send("a")

$MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"

$var = FileSaveDialog( "Choose a name.", $MyDocsFolder, "Web Page, complete (*.htm;*.html)", 3)

;option 3 = dialog remains until valid path/file selected

Send(_DateTimeFormat( _NowCalc(),1))

;Send("{enter}")

;Sleep(2500)

;Now quit by pressing Alt-f and then c (File menu -> Close)

WinWaitClose("Save Web Page")

Send("!f")

Send("c")

Sleep(2500)

MsgBox(0, "Thank you", "Today's Black Box has been Saved" & @CRLF & "See you tomorrow")

Share this post


Link to post
Share on other sites



Hello everyone out there. This is my first experience using autoit so forgive me if the questions I ask aren't right. Also, I am a graphic/web designer by trade and writing code has proven to be my nemesis. At any rate allow me to move along. The company I work for needs to have certain pages that display real time data saved at certain points in the day to a specific directory. I have been able to open internet explorer to the correct url and open the save as window to the correct directory. I cannot figure out how to have autoit type a file name to save the document as. I am trying to use the current date as the file name. I have included the date.au3 file that came with the program when it was installed. Here is the code I am wishing to use can anyone help me trouble shoot it.

-----------------------------------------------------------------------------------------------------

#include <Date.au3>

;Run and open internet explorer to the site needed and saving.

;Run IE

Run("C:\Program Files\Internet Explorer\iexplore.exe http://www.ourwebsitepage.html")

;We wait for the webpage here

WinWaitActive("http://www.ourwebsitepage.html - Microsoft Internet Explorer")

Sleep(5000)

;Save it

Send("!f")

Send("a")

$MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"

$var = FileSaveDialog( "Choose a name.", $MyDocsFolder, "Web Page, complete (*.htm;*.html)", 3)

;option 3 = dialog remains until valid path/file selected

Send(_DateTimeFormat( _NowCalc(),1))

;Send("{enter}")

;Sleep(2500)

;Now quit by pressing Alt-f and then c (File menu -> Close)

WinWaitClose("Save Web Page")

Send("!f")

Send("c")

Sleep(2500)

MsgBox(0, "Thank you", "Today's Black Box has been Saved" & @CRLF & "See you tomorrow")

how about just:

$blah = InetGet("Ourpage.com/index.html",@MyDocumentsDir & "\" & @year & "-" & @MON & "-" & @MDAY & "--" & @HOUR & @MIN & ".html")
MsgBox(0,"Saved","The page has been saved")

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

how about just:

$blah = InetGet("Ourpage.com/index.html",@MyDocumentsDir & "\" & @year & "-" & @MON & "-" & @MDAY & "--" & @HOUR & @MIN & ".html")
MsgBox(0,"Saved","The page has been saved")
Thank you for the prompt response.

Would that go after opening the page and before the save as or would it be just after you have begun the save as function?

Share this post


Link to post
Share on other sites

Thank you for the prompt response.

Would that go after opening the page and before the save as or would it be just after you have begun the save as function?

InetGet() will only save the HTML code of the page, no images and other parts. So, it's different from File->Save within Internet Explorer. So, what's on that page? Just plain text, or some images you want to safe as well?

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

InetGet() will only save the HTML code of the page, no images and other parts. So, it's different from File->Save within Internet Explorer. So, what's on that page? Just plain text, or some images you want to safe as well?

Cheers

Kurt

Well, I got that first one. Now I have to do the same for a username/password protected page with graphics on it. Any suggestions?

Share this post


Link to post
Share on other sites

Well, I got that first one. Now I have to do the same for a username/password protected page with graphics on it. Any suggestions?

wget for windows (google it). and then run() the following command:

wget -p -q --http-user=USERNAME --http-passwd=PASSWORD http://www.mypage.com/funny.html

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

wget for windows (google it). and then run() the following command:

wget -p -q --http-user=USERNAME --http-passwd=PASSWORD http://www.mypage.com/funny.html

Cheers

Kurt

Thank you for the reply again, dev. However, is there another alternative to downloading more software to a highly valuable computer? I have seen something about InetGet and specifying a username and password but, the page just hangs and the script pauses. Here is my code example:

WinWaitActive("https://www.oursite.com/passwordedpage - Microsoft Internet Explorer")

InetGet("https://username:password@www.oursite.com/passwordedpage")

Any suggestions for that?

Share this post


Link to post
Share on other sites

is there a way to save dynamic web pages, like php?

Share this post


Link to post
Share on other sites

Yep.. but you will get the genereated html - NOT the php functions... They are executed before they ever leave the server


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

Yep.. but you will get the genereated html - NOT the php functions... They are executed before they ever leave the server

i want to save the generated html including graphics, automatically, but how to do that, without visiting each page and save it manually?

i tryed wget but something isn`t working. all files saved had each 2,2kb.

Share this post


Link to post
Share on other sites

Well to download a page you need a link... as I understand you want a whole homepage... Then you'll have to use some kind of a crawler to check all the links.. I'll recommend FlashGet or something.. Downloading an entire webpage is not easy (espasially - cant spell - not when its generated)


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

Came across here by coincidence... Not really about AutoIt code but this might save you some time.

I've "ripped-and-saved" quite some websites with some of the freeware tools from: http://www.dirfile.com/internet_networking..._browsers-1.htm

Especially the BackStreet Browser works fine for me... It speaks multiple protocols, you can set what and what not to download by nice filter rules, and you can set proxy and authentication. Note that it is freeware.

Don't know if you can or want to use it, if not sorry to bother :whistle:


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
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
Sign in to follow this  
Followers 0