batch – How to make a program download images from a website, page by page, using id?

Question:

I need to download several images from a website, where only the page number changes, but the img tag id is always the same.

I would like to know if there is a way to create a program that makes this download and the page change, automatically .

The id is #backgroundImg . The page ?page=96 , for example. It can in any language or medium.

I made this code, but I still can't download it.

D:\>FOR %A IN (1,1,96) DO
    wget -A.jpg  http://www.servidor.com.br/#/edition/T3916843A?page=%Asection=1

I'm using wget from the command prompt .

Answer:

The syntax of the loop for is incorrect to declare and use a parameter for it is necessary to prefix it with %% . It is also necessary to use /L to make the range .

FOR /l %%A in (1, 1, 96) DO (
  :: Aqui você usa o wget para baixar o arquivo
  ECHO http://www.servidor.com.br/#/edition/T3916843A?page=%%Asection=1
)
PAUSE

powershell

An alternative in Powershell:

1..96 | % { $paginas  += @{ $_ = "http://www.servidor.com.br/#/edition/T3916843A?page=$_`section=1"} }
$webClient = new-object System.Net.WebClient

foreach ($pagina in $paginas.getEnumerator()) {
   $webClient.DownloadFile($pagina.Value, "img$($pagina.Name)")
}
Scroll to Top