Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rakashash/webscrape-google-image-down
Download google images using python
https://github.com/rakashash/webscrape-google-image-down
beautifulsoup beautifulsoup4 pip python python3 requests
Last synced: 7 days ago
JSON representation
Download google images using python
- Host: GitHub
- URL: https://github.com/rakashash/webscrape-google-image-down
- Owner: RaKAsHASH
- Created: 2022-11-30T05:35:08.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-07T06:19:13.000Z (21 days ago)
- Last Synced: 2024-12-07T07:20:10.438Z (21 days ago)
- Topics: beautifulsoup, beautifulsoup4, pip, python, python3, requests
- Language: Python
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Google Image Scraper
## Overview
This Python script allows users to search and download images directly from Google Images by providing a search query and specifying the number of images to download. It uses the `requests` library to fetch the data and `BeautifulSoup` for HTML parsing.## Features
- **Custom Search**: Specify the type of images to download.
- **Download Control**: Set the number of images to fetch and save.
- **Folder Management**: Automatically creates a folder to store the downloaded images.## Requirements
- Python 3.x
- The following Python libraries:
- `requests`
- `bs4` (BeautifulSoup)## Installation
1. Clone the repository:
```bash
git clone https://github.com/RaKAsHASH/google-image-scraper.git
cd google-image-scraper
2. Install the required libraries:
```bash
pip install requests beautifulsoup4## Usage
1. Run the script:
```bash
python scraper.py
2. Enter the type of images you want to download (e.g., "cats" or "landscapes").
3. Specify the number of images to download.## How It Works
1. The script sends a search request to Google Images with the user-specified query.
2. It parses the HTML response to extract image links using BeautifulSoup.
3. Downloads the specified number of images and saves them in the Images_1 folder.## Code Explanation
### Main Components
- **User Agent Setup**: Mimics a browser to avoid being blocked by Google.
- **Image Download Logic**: Extracts image links from the HTML and downloads them using requests.
### Key Functions
`main()`: Initializes the folder and starts the download process.
`download_images()`: Handles the search query, fetches image links, and downloads them.## Example
- **Input**:
```bash
Enter images type you want to download: puppies
Enter the number of images you want: 5
- **Output**:
```bash
Found 5 images
Start downloading...
Download Completed!## Notes
- **User Agent**: Update the User-Agent string if it becomes outdated or blocked.
- **Google Restrictions**: Google might block repeated or excessive requests. Use responsibly.
- **Image Quality**: The quality of downloaded images depends on Google's provided links.