#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- #Include #include #include Global $board_first = 17 Global $board_last = 18 Global $board_last = 18 Global $ponychan = "http://www.ponychan.net/chan/rp/" Global $h_path = "Pages\Thumbnails\MD5_index.txt" Global $h_index = StringSplit(FileRead($h_path), @LF) Global $h_queue[1] Global $h_found = False Global $thread_contents DirCreate("Pages") DirCreate("Pages\Thumbnails") DirCreate("Temp") FileDelete("Temp\*.*") ;~ FileDelete("Pages\Thumbnails\*.*") ;~ FileDelete("Pages\*.*") FileCopy($h_path, $h_path&".bak", 1) ;~ MsgBox(0, "", $h_path&".bak") $h_file = FileOpen($h_path, 2) ;Download the pages on the board Download_Board() ;HTML archiving loop For $board_current = $board_first to $board_last ; Get the pages on the current board $thread_array = Strip_Page($board_current) ; Download each thread in turn For $thread_download In $thread_array Download_Thread($thread_download) Next Next ;Wait for all thread downloads to complete While InetGetInfo() > 0 Sleep(200) WEnd ;HTML processing loop $thread_array = _FileListToArray("Temp", "*.html", 1) For $thread_file In $thread_array Html_Cleanup($thread_file) Next For $h_dump = 1 To UBound($h_index)-1 FileWrite($h_file, $h_index[$h_dump]&@LF) Next FileClose($h_file) ;############################### ;####### Functions ############# ;############################### ;Download the pages Func Download_Board() For $page = $board_first to $board_last InetGet($ponychan&$page&".html", "Temp\"&$page&".html", 1, 1) ;Wait until thumbnails are downloaded While InetGetInfo() > 0 TrayTip("Downloading board pages ", "Now downloading page: "&$page, 10) Sleep(500) WEnd Next Throttle(0, 1) EndFunc ;Download individual threads Func Download_Thread($x1) $thread_file = StringTrimLeft($x1, 36) InetGet($x1, "Temp\"&$thread_file, 1, 1) Throttle(10, 2) EndFunc ;Download images Func Download_Image($raw_line, $line_number) Local $return[3] $image_URL = StringMid($raw_line, (StringInStr($raw_line, '"', 1, 3)+1), (StringInStr($raw_line, '"', 1, 4))-(StringInStr($raw_line, '"', 1, 3))-1) $image_file = StringMid($raw_line, (StringInStr($raw_line, '/', 1, 6)+1), (StringInStr($raw_line, '"', 1, 4))-(StringInStr($raw_line, '/', 1, 6))-1) ;Check for matching filenames $check = Hash_Check($image_file) If $check = False Then _ArrayAdd($h_queue, $line_number&"|"&$image_file) InetGet($image_URL, "Temp\"&$image_file, 0, 1) Throttle(50, 3) ;~ MsgBox(0, UBound($h_queue),$line_number&"|"&$image_file) Return False ;If the file exists in the hashlist ElseIf $check > 0 Then $hash_entry = StringSplit($h_index[$check], "|,") ;~ MsgBox(0, "DI 2", $hash_entry[2]) $thread_contents[$line_number] = StringReplace($thread_contents[$line_number], $image_URL, "Thumbnails\"&$hash_entry[2]) Return True Else MsgBox(0, "", "Something is wrong...") EndIf EndFunc Func Throttle($x1, $x2) While InetGetInfo() > $x1 Sleep($x2*1000) WEnd EndFunc Func Strip_Page($x1) TrayTip("Please wait...", "Searching for links on page "&$x1, 5) Local $thread_array[1], $thread_loc $page_array = StringSplit(FileRead("Temp\"&$x1&".html"), @CRLF, 1) TrayTip("Please wait", "Searching for thread links...", 10) For $x2 = 1 to $page_array[0]-1 If StringLeft($page_array[$x2], 46) = '[View]' Then $thread_loc = StringTrimLeft($page_array[$x2], 10) $thread_loc = StringTrimRight($thread_loc, 11) ;############## DELETE THIS PART LATER!!! ;~ If $thread_loc = 'http://www.ponychan.net/chan/rp/res/37747963.html' Then _ArrayAdd($thread_array, $thread_loc) ;~ EndIf EndIf Next FileDelete("Temp\"&$x1&".html") Return($thread_array) EndFunc Func Html_Cleanup($thread_file) TrayTip("Processing thread "&$thread_file, "Stripping excess HTML...", 5) ReDim $h_queue[1] $thread_contents = StringReplace(FileRead("Temp\"&$thread_file), @CRLF, @LF) $thread_contents = StringTrimLeft($thread_contents, StringInStr($thread_contents, '')-1) $thread_contents = ''&$thread_contents $thread_contents = StringLeft($thread_contents, StringInStr($thread_contents, '