Created
November 30, 2022 02:22
-
-
Save westoncampbell/2f395531eb31caccb41ae1d5870e6d1d to your computer and use it in GitHub Desktop.
Scrape Top Rated Games Featured On The TIC-80 Website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Script Information =========================================================== | |
; Name: TIC-80 / Top Games | |
; Description: Top Rated Games Featured On The TIC-80 Website | |
; AHK Version: 1.1.35.00 (Unicode 32-bit) | |
; OS Version: Windows 10 | |
; Language: English (United States) | |
; Author: IAmTheDewd | |
; Filename: TIC-80 - Top Games.ahk | |
; ============================================================================== | |
; Revision History ============================================================= | |
; Revision 01 (2022-11-29) | |
; * Initial release | |
; ============================================================================== | |
; Auto-Execute ================================================================= | |
#SingleInstance, Force ; Allow only one running instance of script | |
#Persistent ; Keep the script permanently running until terminated | |
#NoEnv ; Avoid checking empty variables for environment variables | |
SetWorkingDir, % A_ScriptDir ; Set the working directory of the script | |
SetBatchLines, -1 ; The speed at which the lines of the script are executed | |
;OnExit("OnUnload") ; Run a subroutine or function when exiting the script | |
Carts := {} | |
PageIndex := 0 | |
Loop, 29 { | |
HttpReq := ComObjCreate("WinHttp.WinHttpRequest.5.1") | |
HttpReq.Open("GET", "https://tic80.com/play?cat=0&sort=2&page=" PageIndex, false) | |
HttpReq.Send() | |
HttpReq.WaitForResponse() | |
Pos := 0 | |
While (Pos := RegExMatch(HttpReq.ResponseText, "s)play\?cart=(\d+)", MatchCart, Pos + 1)) { | |
Carts.Push({Page: PageIndex + 1, Cart: MatchCart1}) | |
Pos += StrLen(MatchCart) | |
} | |
PageIndex++ | |
} | |
For Index, Carts In Carts { | |
HttpReq := ComObjCreate("WinHttp.WinHttpRequest.5.1") | |
HttpReq.Open("GET", "https://tic80.com/play?cart=" Carts.Cart, false) | |
HttpReq.Send() | |
HttpReq.WaitForResponse() | |
If (HttpReq.ResponseText = "<p>404. Not Found!</p>") { | |
Continue | |
} | |
RegExMatch(HttpReq.ResponseText, "s)(\/cart\/\S+\/(\S+)\.tic)", MatchDownload) | |
IfNotExist, % Format("{:02}", Carts.Page) | |
{ | |
FileCreateDir, % Format("{:02}", Carts.Page) | |
} | |
UrlDownloadToFile, % "https://tic80.com" MatchDownload1, % Format("{:02}", Carts.Page) "\" Format("{:02}", Index) " - " MatchDownload2 " (Cart " Carts.Cart ").tic" | |
} | |
MsgBox, Done | |
ExitApp | |
return ; End automatic execution | |
; ============================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment