corgano Posted October 26, 2009 Posted October 26, 2009 (edited) How would I make a script get all the files in a url, say here, and have my program list all the files in that directory? Edited October 26, 2009 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e
exodius Posted October 26, 2009 Posted October 26, 2009 Assuming that any additional files on that page will follow the same format: #include <Array.au3> #include <IE.au3> $oIE = _IECreate ("http://corgano.co.cc/new/") $sHTML = _IEDocReadHTML ($oIE) $sRegExp = StringRegExp ($sHTML, '(?:\"\>)(.*)(?:\<\/A>)', 3) If @error Then MsgBox (0, "", @error) _ArrayDisplay ($sRegExp) For $x = 1 To UBound($sRegExp)-1 MsgBox (0, "", $sRegExp[$x]) Next
corgano Posted October 26, 2009 Author Posted October 26, 2009 Assuming that any additional files on that page will follow the same format: #include <Array.au3> #include <IE.au3> $oIE = _IECreate ("http://corgano.co.cc/new/") $sHTML = _IEDocReadHTML ($oIE) $sRegExp = StringRegExp ($sHTML, '(?:\"\>)(.*)(?:\<\/A>)', 3) If @error Then MsgBox (0, "", @error) _ArrayDisplay ($sRegExp) For $x = 1 To UBound($sRegExp)-1 MsgBox (0, "", $sRegExp[$x]) Next Any way of doing it without opening internet explorer? (or any other window) 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e
exodius Posted October 26, 2009 Posted October 26, 2009 (edited) If you're trying to avoid opening an IE window... Would you be able to at least save a file to the computer with INetGet and then read it in with _FileReadToArray and then parse it out like I did, or do you need to get the html completely without saving something to the computer?***Edit - I would also point out that you can have that IE window be hidden if you change the _IECreate to _IECreate ("http://corgano.co.cc/new/", 0, 1), you'd just want to add _IEQuit($oIE) to the end of what I posted so you didn't end up with orphaned iexplore.exe processes. Edited October 26, 2009 by exodius
corgano Posted October 26, 2009 Author Posted October 26, 2009 If you're trying to avoid opening an IE window... Would you be able to at least save a file to the computer with INetGet and then read it in with _FileReadToArray and then parse it out like I did, or do you need to get the html completely without saving something to the computer?***Edit - I would also point out that you can have that IE window be hidden if you change the _IECreate to _IECreate ("http://corgano.co.cc/new/", 0, 1), you'd just want to add _IEQuit($oIE) to the end of what I posted so you didn't end up with orphaned iexplore.exe processes.I tried to have the window hidden ($oIE = _IECreate ("http://corgano.co.cc/new/",0,1))but it didnt work.What would I use inetget on? 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e
exodius Posted October 27, 2009 Posted October 27, 2009 My bad, I gave you the wrong code for the _IECreate, what I gave you would have told it to make it be visible instead of hidden.This should work:#include <Array.au3> #include <IE.au3> $oIE = _IECreate ("http://corgano.co.cc/new/", 0, 0) $sHTML = _IEDocReadHTML ($oIE) $sRegExp = StringRegExp ($sHTML, '(?:\"\>)(.*)(?:\<\/A>)', 3) If @error Then MsgBox (0, "", @error) _ArrayDisplay ($sRegExp) For $x = 1 To UBound($sRegExp)-1 MsgBox (0, "", $sRegExp[$x]) Next _IEQuit($oIE)
corgano Posted October 27, 2009 Author Posted October 27, 2009 That worked. Thank you. If anyone else has a method then feel free to post it. 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e
exodius Posted October 27, 2009 Posted October 27, 2009 (edited) You could do this too: #include <Array.au3> $varOutput = "temp.html" InetGet ("http://corgano.co.cc/new/", $varOutput) $varFile = FileRead ($varOutput) $sRegExp = StringRegExp ($varFile, '(?:\"\>)(.*)(?:\<\/a>)', 3) If @error Then MsgBox (0, "", @error) _ArrayDisplay ($sRegExp) For $x = 1 To UBound($sRegExp)-1 MsgBox (0, "", $sRegExp[$x]) Next FileDelete ($varOutput) Edited October 27, 2009 by exodius
corgano Posted February 4, 2010 Author Posted February 4, 2010 You could do this too: #include <Array.au3> $varOutput = "temp.html" InetGet ("http://corgano.co.cc/new/", $varOutput) $varFile = FileRead ($varOutput) $sRegExp = StringRegExp ($varFile, '(?:\"\>)(.*)(?:\<\/a>)', 3) If @error Then MsgBox (0, "", @error) _ArrayDisplay ($sRegExp) For $x = 1 To UBound($sRegExp)-1 MsgBox (0, "", $sRegExp[$x]) Next FileDelete ($varOutput) Just visiting the thread again because I am going to do a complete rewrite of the script. Thanks! I like how it needs no includes (array.au3 is only for arraydisplay) 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e
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