If you have amassed quite a collection of favourite wallpapers on Wallhaven and want to download all of them to make yourself a private backup on your PC, this guide will show you how. Before you start, this process is specifically for Windows users using Firefox. So if you are using Google Chrome or another Chromium-based browser on Windows, check out the alternative guide here. The process is quite simple, but the download will take quite a long time if you have a big collection, so keep that in mind.
Takeaways:
- Is there a way to download all of the wallpapers you added to favouites in Wallhaven?
- How do you download everything from your Wallhaven Favorites library?
Table of Contents
Before you Start Downloading your Wallhaven Favourites
This process can take a long time, especially if you have a large Favorites collection since the downloader needs to do all of the following things:
- Check every page of your Favorites.
- Visit each individual wallpaper page.
- Find the original image.
- Download the image.
- Respect Wallhaven's rate limits: pause for 10 seconds every 15 downloads.
Note: When this happens, the script waits before continuing. Do not close the PowerShell window while it is running.
1. Install Python
Download and install Python for Windows.
If you don't already have Python:
- Open PowerShell.
- Run:
winget install Python.Python.3.13

- Close and reopen PowerShell.
- Check:
py --version
If you see a Python version, such as Python 3.13.x, Python is ready.
2. Create a folder
Open File Explorer and create a folder where you will keep the downloader.
For example:
C:\Users\YourName\Downloads\Wallhaven Collection
3. Create the downloader script
Inside the folder, open Notepad and create a new text document called:
wallhaven_favorites.py
Make sure the file ends in .py, not .txt.
Open the file with Notepad and paste the following script:
import os
import re
import sys
import time
import requests
import browser_cookie3
from bs4 import BeautifulSoup
from urllib.parse import urljoin
BASE_URL = "https://wallhaven.cc"
FAVORITES_URL = f"{BASE_URL}/favorites"
DOWNLOAD_DIR = os.path.join(
os.path.expanduser("~"),
"Pictures",
"Wallhaven Favorites"
)
REQUEST_DELAY = 1.0
DOWNLOADS_BEFORE_PAUSE = 15
RATE_LIMIT_PAUSE = 10
def create_session():
print()
print("=" * 70)
print("WALLHAVEN FAVORITES DOWNLOADER")
print("=" * 70)
print()
print("Reading your Firefox Wallhaven login session...")
print()
try:
cookies = browser_cookie3.firefox(
domain_name="wallhaven.cc"
)
except Exception as e:
print()
print("Could not read Firefox cookies.")
print()
print("Make sure Firefox is installed and")
print("that you are logged into Wallhaven.")
print()
print("Error:", e)
sys.exit(1)
if not cookies:
print()
print("No Wallhaven cookies were found.")
print()
print("Open Firefox, log into Wallhaven,")
print("visit https://wallhaven.cc/favorites,")
print("and run this script again.")
sys.exit(1)
session = requests.Session()
for cookie in cookies:
session.cookies.set(
cookie.name,
cookie.value,
domain=cookie.domain,
path=cookie.path
)
session.headers.update({
"User-Agent": (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/140.0 Safari/537.36"
)
})
return session
def request(session, url, **kwargs):
for attempt in range(5):
try:
response = session.get(
url,
timeout=30,
allow_redirects=True,
**kwargs
)
if response.status_code == 429:
wait = 10 * (attempt + 1)
print(f"\nRate limited. Waiting {wait} seconds...")
time.sleep(wait)
continue
response.raise_for_status()
return response
except requests.RequestException as e:
if attempt == 4:
raise
print()
print("Request failed:", e)
print("Retrying...")
time.sleep(5)
raise RuntimeError("Request failed.")
def get_favorite_pages(session):
print("Checking your Favorites...")
response = request(
session,
FAVORITES_URL
)
soup = BeautifulSoup(
response.text,
"html.parser"
)
links = soup.select('a[href*="/w/"]')
if not links:
print()
print("No wallpapers were found.")
print()
print("Make sure you are logged into Wallhaven")
print("in Firefox and can see your Favorites.")
print()
sys.exit(1)
pages = {1}
for link in soup.select("a[href]"):
href = link.get("href", "")
match = re.search(
r"[?&]page=(\d+)",
href
)
if match:
pages.add(int(match.group(1)))
max_page = max(pages)
print(f"Detected {max_page} page(s).")
return max_page
def extract_wallpaper_urls(html):
soup = BeautifulSoup(
html,
"html.parser"
)
urls = set()
for link in soup.select('a[href*="/w/"]'):
href = link.get("href", "")
match = re.search(
r"/w/([A-Za-z0-9]+)",
href
)
if match:
wallpaper_id = match.group(1)
urls.add(
f"{BASE_URL}/w/{wallpaper_id}"
)
return sorted(urls)
def get_original_image(session, wallpaper_url):
response = request(
session,
wallpaper_url
)
soup = BeautifulSoup(
response.text,
"html.parser"
)
image = soup.select_one(
"img#wallpaper"
)
if image and image.get("src"):
return urljoin(
BASE_URL,
image["src"]
)
og = soup.select_one(
'meta[property="og:image"]'
)
if og and og.get("content"):
return urljoin(
BASE_URL,
og["content"]
)
return None
def safe_filename(filename):
return re.sub(
r'[<>:"/\\|?*]',
"_",
filename
)
def download_image(session, image_url, wallpaper_id):
os.makedirs(
DOWNLOAD_DIR,
exist_ok=True
)
filename = image_url.split("/")[-1]
if not filename:
filename = f"wallhaven-{wallpaper_id}.jpg"
filename = safe_filename(filename)
path = os.path.join(
DOWNLOAD_DIR,
filename
)
if (
os.path.exists(path)
and os.path.getsize(path) > 0
):
return "exists"
for attempt in range(5):
try:
with session.get(
image_url,
stream=True,
timeout=60,
headers={
"Referer": BASE_URL + "/"
}
) as response:
if response.status_code == 429:
wait = 10 * (attempt + 1)
print(
f"\nRate limited. "
f"Waiting {wait} seconds..."
)
time.sleep(wait)
continue
response.raise_for_status()
temp_path = path + ".part"
with open(
temp_path,
"wb"
) as f:
for chunk in response.iter_content(
chunk_size=1024 * 1024
):
if chunk:
f.write(chunk)
os.replace(
temp_path,
path
)
return "downloaded"
except requests.RequestException as e:
if attempt == 4:
print(
f"\nFAILED: {wallpaper_id}: {e}"
)
return "failed"
time.sleep(5)
return "failed"
def main():
session = create_session()
print("Firefox session loaded.")
print()
print("Download directory:")
print(DOWNLOAD_DIR)
print()
max_page = get_favorite_pages(session)
all_wallpapers = []
print()
print("Collecting wallpaper IDs...")
print()
for page in range(1, max_page + 1):
url = FAVORITES_URL
if page > 1:
url += f"?page={page}"
print(
f"Reading page {page}/{max_page}...",
end="",
flush=True
)
try:
response = request(
session,
url
)
wallpapers = extract_wallpaper_urls(
response.text
)
print(
f" {len(wallpapers)} wallpapers"
)
all_wallpapers.extend(wallpapers)
except Exception as e:
print(f" ERROR: {e}")
time.sleep(REQUEST_DELAY)
all_wallpapers = list(
dict.fromkeys(all_wallpapers)
)
print()
print("=" * 70)
print(
f"Found {len(all_wallpapers)} "
f"favorite wallpapers."
)
print("=" * 70)
print()
downloaded = 0
skipped = 0
failed = 0
for number, wallpaper_url in enumerate(
all_wallpapers,
1
):
wallpaper_id = (
wallpaper_url
.rstrip("/")
.split("/")[-1]
)
print(
f"[{number}/{len(all_wallpapers)}] "
f"Wallpaper {wallpaper_id}...",
end="",
flush=True
)
try:
image_url = get_original_image(
session,
wallpaper_url
)
if not image_url:
print(" NO IMAGE FOUND")
failed += 1
continue
result = download_image(
session,
image_url,
wallpaper_id
)
if result == "downloaded":
downloaded += 1
print(" downloaded")
if downloaded % DOWNLOADS_BEFORE_PAUSE == 0:
print()
print(
f"Downloaded {downloaded} images. "
f"Pausing for {RATE_LIMIT_PAUSE} seconds..."
)
time.sleep(RATE_LIMIT_PAUSE)
elif result == "exists":
skipped += 1
print(" already exists")
else:
failed += 1
print(" FAILED")
except Exception as e:
failed += 1
print(f" ERROR: {e}")
time.sleep(REQUEST_DELAY)
print()
print("=" * 70)
print("DONE")
print("=" * 70)
print()
print(f"Downloaded : {downloaded}")
print(f"Skipped : {skipped}")
print(f"Failed : {failed}")
print()
print("Files are in:")
print(DOWNLOAD_DIR)
print()
if __name__ == "__main__":
main()
Save the file after pasting the script.
4. Install the required packages
Open PowerShell and run:
py -m pip install requests beautifulsoup4 browser-cookie3
Wait for the installation to finish.
5. Log in to Wallhaven
Open Firefox and log in to your Wallhaven account.
Open: https://wallhaven.cc/favorites
Make sure your Favorites are visible.
Leave Firefox open while the downloader is running.
6. Start the downloader
In PowerShell, go to the folder containing the script.
For example:
cd "C:\Users\YourName\Downloads\Wallhaven Collection"
Then run:
py wallhaven_favorites.py
The script will detect your Firefox Wallhaven session and begin scanning your Favorites.
You should see something similar to:
Reading page 1/50... 24 wallpapers
Reading page 2/50... 24 wallpapers
Reading page 3/50... 24 wallpapers

Once all the pages have been checked, it will begin downloading the wallpapers.
7. It's going to take ages to download everything!
The download can take a hell of a long time for a big collection. My 12,000 image collection took half a day with 1 GB fibre up/down. Wallhaven limits how frequently requests can be made. The script pauses for 10 seconds after every 15 successful downloads, and it will also wait and retry if the server returns a rate-limit response. This is why the process is super slow.
Do not close PowerShell while the script is running.
You can safely leave it running in the background.

8. Find your downloaded wallpapers
The wallpapers are automatically saved to:
C:\Users\YourName\Pictures\Wallhaven Favorites
You can view them as they are being downloaded if you want to. Just don't close Firefox or the PowerShell window. It took 9 hours to download 11938 images and 30 GB of storage space. The good news is that it will pause and reconnect if your connection breaks. However, if you close the PowerShell window, the script will stop and you will need to start it again.

Once you are done, you can uninstall everything except Python using the following command:
py -m pip uninstall requests beautifulsoup4 browser-cookie3
It's not required, but if you don't think you'll need it for a while, you might as well get rid of it. You can remove Python from the Control Panel as you would any other bit of software.