This repository contains a Python script to automate the process of scraping images from Google Images using Selenium. The script downloads high-quality images based on the provided search query and saves them locally.
- Automated Google Images search using Selenium.
- Downloads high-quality images.
- Saves images in a specified folder.
- Handles dynamic content loading with WebDriverWait.
- Python 3.7+
- Google Chrome
- Chromedriver (managed automatically with
webdriver_manager)
-
Clone the repository:
git clone https://github.com/mebrahimi12/Scraping-Google-Images-using-Selenium.git cd Scraping-Google-Images-using-Selenium -
Install the required dependencies:
pip install -r requirements.txt
-
Make sure Google Chrome is installed and up to date.
-
Open the
Scraping.pyscript and edit thesearch_urlvariable with your desired Google Images search query. -
Run the script:
python Scraping.py
-
The images will be saved in the
model_imagesfolder.
The script performs the following steps:
- Creates a folder for storing images.
- Sets up Selenium WebDriver with custom preferences and user-agent.
- Opens Google Images and searches for the specified query.
- Scrapes high-quality images and saves them locally.
- Handles errors and retries if needed.
After running the script, the downloaded images will be saved in a folder named model_images. For example:
model_images/
├── model_1.jpg
├── model_2.jpg
├── model_3.jpg
...
- Google might block requests after multiple queries. To mitigate this, use proxies or add delays between requests.
- The script relies on specific CSS selectors that might change over time, causing it to break. Update the selectors if necessary.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Feel free to fork the repository, submit issues, or create pull requests.
- Selenium for browser automation.
- Webdriver Manager for managing Chromedriver.