Herb191 Posted September 28, 2014 Posted September 28, 2014 I am getting a corrupt Excel file when I use InetGet(). $sFilePath = @ScriptDir & "\List.xls" $sDownloadURL = "https://alachua.lienexpress.net/certificates/list.xls?q=%7B%7D%0A" $hDownload = InetGet($sDownloadURL, $sFilePath)
water Posted September 29, 2014 Posted September 29, 2014 How do you know it is corrupt? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Herb191 Posted September 29, 2014 Author Posted September 29, 2014 How do you know it is corrupt? Corrupt in the sense that if I manually go to the URL and download it the file opens fine in Excel. When I use InetGet() and open the file with Excel it says that it is a bad file type.
water Posted September 29, 2014 Posted September 29, 2014 Have you tried flag $INET_FORCERELOAD? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Herb191 Posted September 30, 2014 Author Posted September 30, 2014 Have you tried flag $INET_FORCERELOAD? Sorry for the late response of have been sick the last couple of days. Yes I have tried $INET_FORCERELOAD. The exact message I get from Excel is: The file format and extension of ‘list.xls’ don’t match. The file could be corrupted or unsafe. Unless you trust its source, don’t open it. Do you want to open it anyway? When I open the file its is not readable. When I download the file manually the extension is a .xls.
Danp2 Posted September 30, 2014 Posted September 30, 2014 When I manually download the file, Firefox thinks it downloaded a 223KB file. However, when you examine the actual file it is 992KB. It looks like the file being downloaded with InetGet is compressed. I was able to open it with 7Zip and extract the same 992KB file from within. Latest Webdriver UDF Release Webdriver Wiki FAQs
Herb191 Posted September 30, 2014 Author Posted September 30, 2014 When I manually download the file, Firefox thinks it downloaded a 223KB file. However, when you examine the actual file it is 992KB. It looks like the file being downloaded with InetGet is compressed. I was able to open it with 7Zip and extract the same 992KB file from within. Hummm very interesting. I was also able to read it once I unzipped it. I guess I will have to use InetGet() to get the file and then have AutoIt unzip it. Thanks Danp2.
Herb191 Posted September 30, 2014 Author Posted September 30, 2014 So upon further research I found that the issue was that the file was being downloaded in gzip format. I thought I would post my code for anyone that ran into a similar problem. This code uses the zLib UDF found >here. #include "ZLIB.au3" $sFilePath = @ScriptDir & "\list.xls" $sURL = "https://alachua.lienexpress.net/certificates/list.xls?q=%7B%7D%0A" InetGet_GZ($sURL, $sFilePath) Func InetGet_GZ($sDownloadURL, $sFileName) $Data = InetRead($sDownloadURL) $Data = BinaryToString(_ZLIB_GZUncompress($Data), 1) If FileExists($sFileName) Then FileDelete($sFileName) FileWrite($sFileName, $Data) EndFunc ;==>InetGet_GZ
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now