hunte922 Posted October 6, 2016 Posted October 6, 2016 (edited) Edit: The solution! Maybe? I need to download an image from a website using AutoIt but the download, when viewed in a text editor, does not appear to be the same as if I had downloaded it from a web browser. Could anyone help me figure out why this is happening? I've already tried _INetGetSource, InetGet, _IENavigate, wget, this, and a few .bat and .vbs scripts. Example Code: #include <Inet.au3> Local $source = _INetGetSource("http://c0.rbxcdn.com/0db36a45eae4838667ae9a46ba0c082a") Local $newfile = FileOpen(@ScriptDir & "\test.txt", 2) FileWrite($newfile, $source) FileClose($newfile) Image URL: http://c0.rbxcdn.com/0db36a45eae4838667ae9a46ba0c082a Screenshot attached. Edited October 6, 2016 by hunte922
Muhammad_Awais_Sharif Posted October 6, 2016 Posted October 6, 2016 I have same result on both from Autoit and Browser (Text Editor Notepade++)
genius257 Posted October 6, 2016 Posted October 6, 2016 I got some bizarre results, until i used binary mode flag in fileopen. $sReturn = BinaryToString(InetRead("http://c0.rbxcdn.com/0db36a45eae4838667ae9a46ba0c082a", 8)) $hFile = FileOpen("test.png", 2+16) FileWrite($hFile, $sReturn) FileClose($hFile) this works for me anyways To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
hunte922 Posted October 6, 2016 Author Posted October 6, 2016 (edited) 9 minutes ago, Muhammad_Awais_Sharif said: I have same result on both from Autoit and Browser (Text Editor Notepade++) I just ran the script again and I am still getting the same results. Screenshot attached when viewing the downloaded file in Notepad++. 3 minutes ago, genius257 said: I got some bizarre results, until i used binary mode flag in fileopen. That code gives me the same incorrect result. Edited October 6, 2016 by hunte922
genius257 Posted October 6, 2016 Posted October 6, 2016 Maybe your cache? $sReturn = InetRead("http://c0.rbxcdn.com/0db36a45eae4838667ae9a46ba0c082a", 8+1) $hFile = FileOpen("test.png", 2+16) FileWrite($hFile, $sReturn) FileClose($hFile) All i did was add the flag INET_FORCERELOAD I've just tested my script on another pc, no problems there either. To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
hunte922 Posted October 6, 2016 Author Posted October 6, 2016 (edited) 4 minutes ago, genius257 said: Maybe your cache? Tried your new code. No changes. Have you tried it on the latest version of AutoIt? Edited October 6, 2016 by hunte922
hunte922 Posted October 6, 2016 Author Posted October 6, 2016 Just tried and it still gave me the same incorrect result.
genius257 Posted October 6, 2016 Posted October 6, 2016 I was able to replicate your bug. But now it seems i can't undo it ^^' Maybe it's a result of too many requests i a short time-span to the AmazonS3 server. It's not the first time I've had an issue like that... I will try running the script when i wake up and let you know To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
hunte922 Posted October 6, 2016 Author Posted October 6, 2016 Found something that works. Let's hope it stays that way... RunWait('powershell.exe & { Invoke-WebRequest -Uri "http://c0.rbxcdn.com/0db36a45eae4838667ae9a46ba0c082a" -OutFile "text.txt" }')
Danyfirex Posted October 6, 2016 Posted October 6, 2016 Hello. What's wrong with this way? InetGet("http://c0.rbxcdn.com/0db36a45eae4838667ae9a46ba0c082a","test.txt") Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
genius257 Posted October 6, 2016 Posted October 6, 2016 So i tried again just now, and it works fine again. The error seems to be related to too many server request within a time-frame. So i would suggest checking the downloaded file for a valid image-format and if not wait at least 1hour before trying again. To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
mikell Posted October 6, 2016 Posted October 6, 2016 (edited) Please try this HttpSetUserAgent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)") $sReturn = BinaryToString(InetRead("http://c0.rbxcdn.com/0db36a45eae4838667ae9a46ba0c082a", 8)) $hFile = FileOpen("test.png", 2+16) FileWrite($hFile, $sReturn) FileClose($hFile) Edit 10 times downloaded and still working Edited October 6, 2016 by mikell
genius257 Posted October 7, 2016 Posted October 7, 2016 On 6/10/2016 at 6:27 PM, mikell said: 10 times downloaded and still working I ran my test codes at least 100times in under 1 hour before it started getting weird with the results. To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
hunte922 Posted October 7, 2016 Author Posted October 7, 2016 On 10/6/2016 at 11:27 AM, mikell said: Please try this HttpSetUserAgent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)") $sReturn = BinaryToString(InetRead("http://c0.rbxcdn.com/0db36a45eae4838667ae9a46ba0c082a", 8)) $hFile = FileOpen("test.png", 2+16) FileWrite($hFile, $sReturn) FileClose($hFile) Edit 10 times downloaded and still working 9 minutes ago, genius257 said: I ran my test codes at least 100times in under 1 hour before it started getting weird with the results. I got it to work. The link to the solution is in the original post.
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