mcfr1es Posted August 15, 2004 Posted August 15, 2004 (edited) This is a whopper, first of all, sorry for not posting this in my other topic but I wanted the whole script on the same page (preferably the first) and the other topic will soon not be seen anymore. Secondly, I would like to thank all of the people who helped me complete this script and helped me realize that autoit has ALOT of differences from java. As I have done in the past with my java scripts, I am posting this in hopes that I will recieve many comments on it (how to improve, make it faster, what can be done better, etc.). Again, comments are needed as this is my first script and more than anything I wish to reduce it a bit in size and search time (which is tremendous)..NOTE: dont bother runnig the script (1) takes too long(2)you cant without the forum's username/passexpandcollapse popup; Determining the link on a webpage. ;------------------------------------------------------------------------------ $DATAFILE = "names.txt" $NUMNAMES = 0 Dim $PAGENAMES [ 50 ] [2000]; was getting problems with range exceeded, had no time so i put alot of extra, empty elements -- meh $PAGENAMES = _NameURL() For $AA = 1 To 24 Step 1 For $BB = 1 To 301 Step 50 $SURL = $PAGENAMES [$AA] [$BB] $USERLIST = _GetUsers($SURL) $NUMNAMES = _ScanFile($DATAFILE, $NUMNAMES, $USERLIST) ;MsgBox(0, "boo", "NUMNAMES =" & $NUMNAMES) Next Next Func _GetUsers($PSURL);Searches the URL's provided and returns an array containing 50 usernames Local $SUSERLIST ;Returns an array of links from a webpage ;------------------------------------------------------------------------------ ;Download the HTML to a temporary file $STEMPFILE = "$page.htm" URLDownloadToFile($PSURL, $STEMPFILE) $SHTML = FileRead($STEMPFILE, FileGetSize($STEMPFILE)) FileDelete($STEMPFILE) ;Cleanup the HTML for better consumption $SHTML = StringReplace($SHTML, @CR, "") $SHTML = StringReplace($SHTML, @LF, "") $SHTML = StringReplace($SHTML, @TAB, " ") ;Break it into chewable bytes $SHTML = StringReplace($SHTML, '<span class="blistSmall">', @LF & '<span class="blistSmall">') $ASHTML = StringSplit($SHTML, @LF) ;Spit out the bones For $NX = 1 To $ASHTML[0] ;Process only "<span class="blistSmall">" lines If StringLeft($ASHTML[$NX], 25) = '<span class="blistSmall">' Then $ASUSERLIST = StringTrimLeft($ASHTML[$NX], StringInStr($ASHTML[$NX], ">")) $ASUSERLIST = StringLeft($ASUSERLIST, StringInStr($ASUSERLIST, "<") - 1) $SUSERLIST = $SUSERLIST & @LF & $ASUSERLIST EndIf Next ;Return the juicy links Return StringSplit(StringTrimLeft($SUSERLIST, 1), @LF) EndFunc ;==>_GetUsers Func _NameURL();returns a 2D array containing the URL's of the msg boards to check ;Returns URL of board to look in ;------------------------------------------------------------------------------ For $BOARDNUM = 1 To 24 Step 1 $PAGENAMES [$BOARDNUM] [1] = ("http://www.neopets.com/neoboards/boardlist.phtml?board=" & $BOARDNUM) For $PAGENUM = 51 To 301 Step 50 $PAGENAMES [$BOARDNUM] [$PAGENUM] = ("http://www.neopets.com/neoboards/boardlist.phtml?board=" & $BOARDNUM & "&next=" & $PAGENUM) Next Next Return $PAGENAMES EndFunc ;==>_NameURL Func _ScanFile($FILENAME, $HOWMANY, $USERS);scans files for doubles and prints to the text file Dim $TIMESDIFF [51] If $HOWMANY = 0 Then $HOWMANY = 50 _howmany50($FILENAME, $HOWMANY, $USERS) Else For $TT = 1 To 50 $FILE = FileOpen($FILENAME, 0) $COUNTA = 0 While 1 $LINE = FileReadLine($FILE) If @error = -1 Then ExitLoop $COUNTA = _checknotequal($LINE, $COUNTA, $TT, $USERS) Wend FileClose($FILE) ;MsgBox(0, "boo", "counta =" & $counta & "howmany = " & $howmany) If $COUNTA = $HOWMANY Then ;MsgBox(0, "boo", "ready to print") $HOWMANY = _Print($FILENAME, $USERS, $HOWMANY, $TT) EndIf Next EndIf Return $HOWMANY EndFunc ;==>_ScanFile Func _Print($XFILENAME, $XUSERS, $XHOWMANY, $WQ); if no doubles, prints the names to a text file $FILE = FileOpen($XFILENAME, 1) ; Check if file opened for reading OK If $XFILENAME = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ;MsgBox(0, "boo", $XUSERS [$WQ]) $XHOWMANY = $XHOWMANY + 1 FileWriteLine($FILE, $XUSERS [$WQ]) FileClose($FILE) Return $XHOWMANY EndFunc ;==>_Print Func _howmany50($FILEZ, $MANYZ, $USIEZ);when run for the first time, automatically adds the 50 entries into the text file without a check $FILE = FileOpen($FILEZ, 1) ; Check if file opened for reading OK If $FILE = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf For $TY = 1 To $MANYZ FileWriteLine($FILE, $USIEZ[$TY]) Next FileClose($FILE) EndFunc ;==>_howmany50 Func _checknotequal($LINIA, $COUNT, $QW, $USIEZ);checks if name to be added is equal to next line in file, records # of times that the names are diff and returns If $USIEZ [$QW] <> $LINIA Then $COUNT = $COUNT + 1 EndIf Return $COUNT EndFunc ;==>_checknotequal Edited August 15, 2004 by mcfr1es Roger! You son of a big pile o' Monkey Nuts.
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