Skip to content

Instantly share code, notes, and snippets.

@omarowns
Last active February 13, 2026 23:44
Show Gist options
  • Select an option

  • Save omarowns/5711849 to your computer and use it in GitHub Desktop.

Select an option

Save omarowns/5711849 to your computer and use it in GitHub Desktop.
Bash script to download all issues of The MagPi.
#!/bin/bash
MAGPPI_URL="https://www.raspberrypi.org/magpi-issues/"
function get_issues() {
curl $MAGPI_URL | grep "\"MagPi\d\d\.pdf\"" | grep -o "MagPi\d\d.pdf" | uniq > /tmp/magpi_issues.list
}
function download() {
cat issues.list | xargs printf "https://www.raspberrypi.org/magpi-issues/%s\n" $1 | xargs wget
}
get_issues
download
@impshum
Copy link

impshum commented Apr 10, 2017

I'd just do this.

wget -r -A .pdf https://www.raspberrypi.org/magpi-issues/

@jowdyboy
Copy link

Unfortunately, they put their .pdf downloads behind a POST prompt now, so you can't simply "wget" them.

Also, the URL changed to this format: "https://magazine.raspberrypi.com/issues/###/pdf/download"

Also, from Issue 151 and above, they changed the file names from "MagPi###.pdf" to "RPOM-###.pdf".

I'm a sucker for shitty ChatGPT-generated PowerShell scripts. Here's one I modified that allows you to specify which issues you want to download:



# ===== CONFIG =====
$StartIssue = 122
$EndIssue   = 161
$Dest       = Join-Path $env:USERPROFILE "Downloads\RaspberryPiMag"
# ================

New-Item $Dest -ItemType Directory -Force | Out-Null
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120 Safari/537.36"

for($i=$StartIssue;$i -le $EndIssue;$i++){
  try{
    $landing = "https://magazine.raspberrypi.com/issues/$i/pdf/download"
    $html = (Invoke-WebRequest $landing -Headers @{"User-Agent"=$UA} -MaximumRedirection 10).Content

    # Grab the first absolute PDF URL we can find in the HTML
    $pdf = ([regex]::Match($html,'https?://[^\s"''<>]+\.pdf(\?[^\s"''<>]*)?',"IgnoreCase")).Value
    if(-not $pdf){ Write-Warning "Issue ${i}: no PDF link found"; continue }

    # Use the filename as it exists on the server (from the PDF URL path)
    $name = [IO.Path]::GetFileName(([uri]$pdf).AbsolutePath)
    if(-not $name){ Write-Warning "Issue ${i}: couldn't derive filename"; continue }

    $out = Join-Path $Dest $name
    if(Test-Path $out){ Write-Host "Skip (exists): $name" -ForegroundColor DarkGray; continue }

    Invoke-WebRequest $pdf -Headers @{"User-Agent"=$UA;"Referer"=$landing} -OutFile $out -MaximumRedirection 10
    Write-Host "Saved: $name" -ForegroundColor Green
  } catch {
    Write-Warning "Issue ${i}: $($_.Exception.Message)"
  }
}

Write-Host "`nDone -> $Dest" -ForegroundColor Yellow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment