Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 

Repository files navigation

πŸ–ΌοΈ Image Scraper with Selenium

A flexible Python script to scrape image URLs from any website using Selenium. Just plug in your target URL and CSS selector, and it will fetch image sources with a headless Chrome browser.


πŸš€ Features

  • Headless Chrome automation
  • Scrapes <img> tags or any image-containing elements
  • Works on any site β€” just update the URL and selector
  • Clean and configurable

🧰 Requirements

  • Python 3.7+
  • Google Chrome
  • ChromeDriver (matching your Chrome version)
  • Selenium

πŸ“¦ Install dependencies

pip install selenium

🧱 Install Chrome & ChromeDriver

Use this helper script or install via package manager:

Ubuntu/Debian:

sudo apt install -y chromium-browser chromium-chromedriver

macOS (Homebrew):

brew install --cask google-chrome
brew install chromedriver

Note: Make sure chromedriver is in your system's PATH. You can verify with:

which chromedriver

βš™οΈ Configuration

Update the script with your:

  • Target URL
  • Image CSS selector (defaults to standard <img> tags)

Example snippet to modify:

search_url = "https://example.com/images"
img_elements = driver.find_elements(By.CSS_SELECTOR, "img")  # or your custom selector

🧠 Usage

Run the script:

python main.py

It will prompt you for a URL, open it in a headless browser, and return a list of image URLs.

Example:

Enter page URL: https://example.com/gallery
Image 1: https://...
Image 2: https://...
Image 3: https://...

πŸ›  Script Overview

def fetch_image_urls(url, selector="img", max_results=3):
    # Your scraping logic here

πŸ”„ Change the selector to customize scraping:

  • .photo-class img – nested images
  • div.gallery img – within specific containers
  • img.thumbnail – specific class-based images

πŸ“ Project Structure

.
β”œβ”€β”€ main.py      # Main script

⚠️ Disclaimer

  • Be respectful of website terms of service.
  • This is for educational or authorized use only.
  • Some sites may use lazy-loading or dynamic content (use driver.execute_script() or scroll automation if needed).

About

Scrape images from your favourite websites using selenium based image scraping

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages