Advertisement
BrainWaveCC

GetImageURLs

Jun 23rd, 2024 (edited)
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.93 KB | Source Code | 0 0
  1. @REM - GetImageURLs.BAT (23 Jun 2024 // 24 Jun 2024): Get Image URLs from HTML Download
  2. @ECHO OFF
  3.  
  4.  ::: This script will return the image URLs from an HTML page.  
  5. ::: I performed rudimentary testing only.  It relies on a 3rd party utility:
  6. ::: READABLE.EXE (https://www.majorgeeks.com/files/details/readable.html)
  7. :::
  8. ::: I tested https://www.newgrounds.com/art/view/thewendigo/tree and
  9. ::: https://www.newgrounds.com/art/view/missandydandy/punch-punch-forever
  10. :::
  11. ::: Rather than supply multiple files, I just had the script generate the
  12. ::: search/replace config file used by READABLE.  
  13. :::
  14. ::: Once the files have been parsed, I download them to the %#SAVEDIR% folder.
  15.  
  16.  
  17. :Variables
  18.  SETLOCAL ENABLEDELAYEDEXPANSION
  19.  
  20.  SET #SOURCE1=https://www.newgrounds.com/art/view/thewendigo/tree
  21.  SET #SOURCE2=https://www.newgrounds.com/art/view/missandydandy/punch-punch-forever
  22.  SET #HTML=%TEMP%\HTML_Contents.TXT
  23.  SET #OUTPUT=%TEMP%\Final_Output.TXT
  24.  SET #REPLACE=%TEMP%\Replacement.TXT
  25.  SET #SAVEDIR=%TEMP%\%~n0
  26.  
  27.  
  28.  rem -- Generate Replacement Config File for READABLE
  29. :MakeReplacement
  30.  IF NOT EXIST "%#REPLACE%" (
  31.      ECHO \/;/
  32.      ECHO \";"
  33.      ECHO =;\n
  34.      ECHO ?;\n
  35.      ECHO ";\n
  36.  ) >"%#REPLACE%"
  37.  
  38.  
  39.  rem -- Download HTML and parse it using READABLE and FINDSTR; ignore icons and thumbnails
  40. :ProcessFiles
  41.  ( FOR /F "TOKENS=1* DELIMS==" %%V IN ('SET #SOURCE 2^>NUL') DO (
  42.      CURL "!%%~V!" -o "%#HTML%"
  43.      READABLE "%#HTML%" -f "http:;https:" -x -r "%#REPLACE%" --sk "/thumb;/icons;-icon" | FINDSTR /i ".png .jpg .jpeg"
  44.  )) >"%#OUTPUT%"
  45.  
  46.  
  47.  rem -- Download Images to Save Directory
  48. :DownloadImages
  49.  IF NOT EXIST "%#SAVEDIR%" MD "%#SAVEDIR%" >NUL 2>NUL
  50.  FOR /F "USEBACKQ TOKENS=*" %%F IN ("%#OUTPUT%") DO IF NOT DEFINED #%%~nxF (
  51.      CURL "%%~F" -o "%#SAVEDIR%\%%~nxF"
  52.      SET #%%~nxF=TRUE
  53.  )
  54.  
  55.  
  56. :ExitBatch
  57.  ECHO:
  58.  IF EXIST "%#OUTPUT%" TYPE "%#OUTPUT%"
  59.  IF EXIST "%#SAVEDIR%" DIR "%#SAVEDIR%"
  60.  TIMEOUT 60
  61.  ENDLOCAL
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement