WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: mcjathan on May 25, 2016, 08:34:11 AM

Title: Web Page Changed, Winbatch Script Now Only Download's Gibberish
Post by: mcjathan on May 25, 2016, 08:34:11 AM
Hi all,  I have a Winbatch script that daily downloads this webpage:

     http://www.wrh.noaa.gov/slc/aviation/SLCSRG.php

Recently, the provider of this page did a major overhaul of the page.  My Winbatch script that used to save this page beautifully now downloads gibberish. Here's the relevant Winbatch code:

Quote#DefineFunction Download_File(URL, File)
   If FileExist(File) Then FileDelete(File)
   tophandle = iBegin(0,"","")
   datahandle = IUrlOpen(tophandle,URL)
   iReadData(datahandle,File)
   iClose(datahandle)
   iClose(tophandle)
#EndFunction

Can anyone offer suggestions how I can change my code to once again capture this web-page properly?

Regards,

Jeff
Title: Re: Web Page Changed, Winbatch Script Now Only Download's Gibberish
Post by: td on May 25, 2016, 10:36:53 AM
Likely a javascript issue.  Perhaps try COM Automation instead:

Code (winbatch) Select
url = 'http://www.wrh.noaa.gov/slc/aviation/SLCSRG.php'
file = 'C:\temp\dump.txt'
If FileExist(File) Then FileDelete(File)
objMsie = ObjectCreate("InternetExplorer.Application")
objMsie.addressbar = @FALSE
objMsie.statusbar = @FALSE
objMsie.menubar = @FALSE
objMsie.toolbar = @FALSE
objMsie.visible = @FALSE
objMsie.navigate(url)
While objMsie.busy || objMsie.readystate <> 4
   TimeDelay(0.5)
EndWhile
FilePut(file,objMsie.document.GetElementsByTagName("HTML").item(0).outerHTML)
objMsie.quit
objMsie = 0
Run('notepad.exe', file)


There are more and better examples in the Tech Database.