mud409 Posted February 6, 2008 Share Posted February 6, 2008 (edited) someone helped me out here a few days ago with a script that reads a websites source and then turns it into an array... this is it $source=_INetGetSource('http://website.com/?txtdisplayedusingphp') $source=StringStripCR($source) $source=StringSplit($source, chr(10)) $source[1] will be the first line $source[2] will be second I'm now trying to use this same concept to break apart a text file I think this should work but it doesn't $file = FileOpen("list.txt", 0) $source2 = FileRead($file, 1) $source2=StringStripCR($source2) $source2=StringSplit($source2, chr(10)) where am I going wrong here? Edited February 6, 2008 by mud409 Link to comment Share on other sites More sharing options...
erezlevi Posted February 6, 2008 Share Posted February 6, 2008 (edited) someone helped me out here a few days ago with a script that reads a websites source and then turns it into an array... this is it $source=_INetGetSource('http://website.com/?txtdisplayedusingphp') $source=StringStripCR($source) $source=StringSplit($source, chr(10)) $source[1] will be the first line $source[2] will be second I'm now trying to use this same concept to break apart a text file I think this should work but it doesn't $file = FileOpen("list.txt", 0) $source2 = FileRead($file, 1) $source2=StringStripCR($source2) $source2=StringSplit($source2, chr(10)) where am I going wrong here? I suggest you use _FileReadToArray and see if that starts helping you, then you can manipulate there... Edited February 6, 2008 by erezlevi Link to comment Share on other sites More sharing options...
mud409 Posted February 6, 2008 Author Share Posted February 6, 2008 thanks, exactly what I needed... Link to comment Share on other sites More sharing options...
mud409 Posted February 6, 2008 Author Share Posted February 6, 2008 (edited) I've got one other problem now... inetget won't allow me to bypass the "filename" paramter. no matter how I try it If I could bypass the filename parameter I THINK the script below should work fine... Below I hacked away at an example included with _filereadtoarray the example displayed msg boxes displaying each line of the text file... ok great I can just use inet instead of msgbox... #include <file.au3> Dim $source2 If Not _FileReadToArray("download.txt",$source2) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $source2[0] InetGet($source2[$x]) Next doesn't work I think because of the filename paramter, also the suttle try at just replacing the msgbox code with inetget code might have it's problems... not really familear with for and next yet... assuming the above script does work, to obtain my filename I should be able to stringsplit and input the array from the stringsplit in as my filename, right? well I think I screwed up with the stringsplit to begin with... but if it did work, how would I obtain the last array it outputs from the split e.g. the filename... I counted down the number of array's the first url should split and it didn't work... so I think my split is screwed up. #include <file.au3> Dim $source2 If Not _FileReadToArray("list.txt",$source2) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $source2[0] $splita = StringSplit($source2[$x], "/") InetGet($source2[$x], $splita[?], 1, 1) Next Edited February 6, 2008 by mud409 Link to comment Share on other sites More sharing options...
erezlevi Posted February 6, 2008 Share Posted February 6, 2008 instead of Inetget use filereadline, you allready download the http info to a file. Link to comment Share on other sites More sharing options...
mud409 Posted February 6, 2008 Author Share Posted February 6, 2008 I'm using inetget to download the file that's on the link stored within the txt file... so I need inetget to actually get the download... InetGet($source2[1], $splita[2], 1, 1) this would work fine assuming I had the filename as the second line in the text file.... Link to comment Share on other sites More sharing options...
erezlevi Posted February 6, 2008 Share Posted February 6, 2008 I'm using inetget to download the file that's on the link stored within the txt file... so I need inetget to actually get the download... InetGet($source2[1], $splita[2], 1, 1) this would work fine assuming I had the filename as the second line in the text file.... I don't understand exactly what isn't working for u, please be more specific. Link to comment Share on other sites More sharing options...
mud409 Posted February 6, 2008 Author Share Posted February 6, 2008 here test the script out for yourself... #include <file.au3> Dim $source2 If Not _FileReadToArray("list.txt",$source2) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $source2[0] $splita = StringSplit($source2[$x], "/") InetGet($source2[$x], $splita[5], 1, 1) Nextcreate a text file with these 2 links in it and name it list.txt place it with the au3 file in the same dir and launch the scripthttp://www.autoitscript.com/cgi-bin/getfil...it-v3-setup.exehttp://www.autoitscript.com/autoit3/scite/downloads.shtmlnow it SHOULD download both these, but it doesn't... Link to comment Share on other sites More sharing options...
mud409 Posted February 6, 2008 Author Share Posted February 6, 2008 For $x = 1 to $source2[0] $splita = StringSplit($source2[$x], chr(47)) InetGet($source2[$x], $splita[0], 1, 1) Next While @InetGetActive TrayTip($splita[0], @InetGetBytesRead, 10, 16) ok this works except that it doesn't grab the file name... it's the last of the array the split string produces but it's random the number of directories the file will be stored in... I never know what array is going to be the file name all I know is it's going to be last... Link to comment Share on other sites More sharing options...
erezlevi Posted February 6, 2008 Share Posted February 6, 2008 For $x = 1 to $source2[0] $splita = StringSplit($source2[$x], chr(47)) InetGet($source2[$x], $splita[0], 1, 1) Next While @InetGetActive TrayTip($splita[0], @InetGetBytesRead, 10, 16) ok this works except that it doesn't grab the file name... it's the last of the array the split string produces but it's random the number of directories the file will be stored in... I never know what array is going to be the file name all I know is it's going to be last... This works for me, but the .exe file fails to download I don't know why... #include <Array.au3> #include <file.au3> Dim $source2 If Not _FileReadToArray("c:\list.txt",$source2) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf _ArrayDisplay ($source2) ;For $x = 1 to $source2[0] MsgBox (0,"this is $source2[1]",$source2[1]) MsgBox (0,"this is $source2[2]",$source2[2]) ;$splita = StringSplit($source2[$x], chr(47)) ;MsgBox (0,"this is $splita",$splita) ;InetGet($source2[$x], $splita[0], 1, 1) InetGet ($source2[1],"c:\ereztestdownload.exe",1,0) InetGet ($source2[2],"c:\ereztestdownload1.shtml",1,0) ; Next While @InetGetActive ; TrayTip($splita[0], @InetGetBytesRead, 10, 16) WEnd Link to comment Share on other sites More sharing options...
Kip Posted February 6, 2008 Share Posted February 6, 2008 This works for me, but the .exe file fails to download I don't know why...firewall? MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
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