How to Scrape High‑Resolution Images from ColorHub with Python
Learn a step‑by‑step Python solution to locate, download, and store high‑resolution, royalty‑free images from ColorHub by navigating its three‑tier page structure, generating request headers, parsing HTML with BeautifulSoup, and saving files locally, enabling offline PPT creation without copyright concerns.
Introduction
Many people need high‑quality, royalty‑free images for PPTs but often wonder where to find them. This article introduces ColorHub, a free image site for personal and commercial use, and shows how to download its pictures to a local library for offline use.
Scraping Approach
The image‑scraping process involves three layers of web pages:
Top‑level page : the search result list obtained from the site’s homepage search bar.
Second‑level page : the detail page of each image clicked from the list.
Target page : the actual high‑resolution image URL embedded in the detail page’s source code.
The following diagrams illustrate the three layers:
# import third‑party packages
import requests
from bs4 import BeautifulSoup
import random
import time
from fake_useragent import UserAgent
# loop through pages 1‑10
for page in range(1, 11):
fst_url = f'https://colorhub.me/search?tag=data&page={page}'
UA = UserAgent()
fst_response = requests.get(fst_url, headers={'User-Agent': UA.random})
fst_soup = BeautifulSoup(fst_response.text)
sec_urls = [i.find('a')['href'] for i in fst_soup.findAll(name='div', attrs={'class':'card'})]
pic_names = [i.find('a')['title'] for i in fst_soup.findAll(name='div', attrs={'class':'card'})]
for sec_url, pic_name in zip(sec_urls, pic_names):
UA = UserAgent()
ua = UA.random
sec_response = requests.get(sec_url, headers={'User-Agent': ua})
sec_soup = BeautifulSoup(sec_response.text)
pic_url = 'https:' + sec_soup.find('img', {'class':'card-img-top'})['src']
pic_response = requests.get(pic_url, headers={'User-Agent': ua})
with open(pic_name + '.jpg', mode='wb') as fn:
fn.write(pic_response.content)
seconds = random.uniform(1, 3)
time.sleep(seconds)Conclusion
Executing the script downloads 325 high‑resolution images from the first ten pages of ColorHub, which can be used offline for PPT creation; you can replace the top‑level URL to scrape other categories such as business, architecture, or plants.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
