Hello everyone,
I am trying to retrieve text from a web page and manipulate it. I use UrlDownloadToFile to download the page, which works perfectly, but when I try and use FileRead on it, it only loads it partially. The worst thing is it worked as it should and then out of the blue just started cutting the text off. I honestly can't figure out what went wrong, can you please help?
As I couldn't upload files directly, being a possible attack vendor , I was forced to use PasteBin. You can view the file that I run FileRead on https://pastebin.com/ZiT83rKH and the content of the variable, the cut off text on https://pastebin.com/VYYXc0wi
Any ideas? I can post my whole script as well, but I don't think it makes any difference. Thanks in advance.
FileRead does not get whole file Topic is solved
Re: FileRead does not get whole file
You could try to download it to a variable instead of a file.
from the help on urldownloadToFile command:
from the help on urldownloadToFile command:
Code: Select all
; Example: Download text to a variable:
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", "https://autohotkey.com/download/1.1/version.txt", true)
whr.Send()
; Using 'true' above and the call below allows the script to remain responsive.
whr.WaitForResponse()
version := whr.ResponseText
MsgBox % version
Re: FileRead does not get whole file
Thanks for the suggestion, I did, but I get the exactly same result.trust_me wrote:You could try to download it to a variable instead of a file.
from the help on urldownloadToFile command:
Code: Select all
; Example: Download text to a variable: whr := ComObjCreate("WinHttp.WinHttpRequest.5.1") whr.Open("GET", "https://autohotkey.com/download/1.1/version.txt", true) whr.Send() ; Using 'true' above and the call below allows the script to remain responsive. whr.WaitForResponse() version := whr.ResponseText MsgBox % version
That's how the issue started happening in the first place, so I moved to saving to a file and FileRead-ing the file to realize it's where it happens as well.
Can someone try and FileRead the attached file and report if you get the same result as I?
Thanks again.
Re: FileRead does not get whole file Topic is solved
It works for me but maybe if you display it using a msgbox it exceeds the max number of characters for a messagebox.
If you display the last characters you can see it is the end of the file.
If you display the last characters you can see it is the end of the file.
Code: Select all
sfile=ZiT83rKH.txt
FileRead, data,%sfile%
filegetsize,len,%sfile%
msgbox % strlen(data) "`n" len
MsgBox, % substr(data,-250)
Re: FileRead does not get whole file
It was a stupid error down the line in the code that was causing issues all along. Thanks for your help!!!!trust_me wrote:It works for me but maybe if you display it using a msgbox it exceeds the max number of characters for a messagebox.
If you display the last characters you can see it is the end of the file.
Code: Select all
sfile=ZiT83rKH.txt FileRead, data,%sfile% filegetsize,len,%sfile% msgbox % strlen(data) "`n" len MsgBox, % substr(data,-250)