Jump to content
Sign in to follow this  

Talk About A Post....

Recommended Posts

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/pass

;  Determining the link on a webpage.
$DATAFILE = "names.txt"
Dim $PAGENAMES [ 50 ] [2000]; was getting problems with range exceeded, had no time so i put alot of extra, empty elements -- meh 

For $AA = 1 To 24 Step 1
  For $BB = 1 To 301 Step 50
    $SURL = $PAGENAMES [$AA] [$BB]
    $USERLIST = _GetUsers($SURL)
  ;MsgBox(0, "boo", "NUMNAMES =" & $NUMNAMES)

Func _GetUsers($PSURL);Searches the URL's provided and returns an array containing 50 usernames
;Returns an array of links from a webpage
;Download the HTML to a temporary file
  $STEMPFILE = "$page.htm"
  $SHTML = FileRead($STEMPFILE, FileGetSize($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)
;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)  
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)
    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)
    ;MsgBox(0, "boo", "counta =" & $counta & "howmany = " & $howmany)
      If $COUNTA = $HOWMANY Then 
      ;MsgBox(0, "boo", "ready to print")
        $HOWMANY = _Print($FILENAME, $USERS, $HOWMANY, $TT) 
  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.")
;MsgBox(0, "boo", $XUSERS [$WQ])
  FileWriteLine($FILE, $XUSERS [$WQ])
  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.")
  For $TY = 1 To $MANYZ
    FileWriteLine($FILE, $USIEZ[$TY])
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
  Return $COUNT
EndFunc  ;==>_checknotequal
Edited by mcfr1es

Roger! You son of a big pile o' Monkey Nuts.

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...