Skip to content

jblayter/hotel_logo_download

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Hotel Logo SVG Downloader

This script downloads SVG logos of hotels from Wikimedia Commons and packages them into a zip file.

Prerequisites

  • Python 3.x
  • Required Python packages:
    • requests
    • beautifulsoup4
    • urllib3

Installation

For macOS Users

  1. Open Terminal and navigate to the project directory:

    cd path/to/hotel_logo_download
  2. Create a virtual environment (required on macOS):

    python3 -m venv venv
  3. Activate the virtual environment:

    source venv/bin/activate

    You should see (venv) appear at the start of your command prompt.

  4. Install the required packages:

    pip install requests beautifulsoup4 urllib3

For Other Operating Systems

  1. Clone this repository or download the script
  2. Create a virtual environment (recommended):
    python -m venv venv
    source venv/bin/activate  # On Linux
    # or
    .\venv\Scripts\activate  # On Windows
  3. Install the required packages:
    pip install requests beautifulsoup4 urllib3

Usage

  1. Make sure your virtual environment is activated (you should see (venv) at the start of your command prompt):

    source venv/bin/activate  # On macOS/Linux
    # or
    .\venv\Scripts\activate  # On Windows
  2. Run the script:

    python download_svgs.py

The script will:

  1. Create a hotel_svgs directory
  2. Download SVG logos from Wikimedia Commons
  3. Create a zip file named hotel_logos_svg.zip containing all downloaded logos

Output

  • The script creates two outputs:
    • A hotel_svgs directory containing individual SVG files
    • A hotel_logos_svg.zip file containing all downloaded SVGs

Features

  • Downloads SVG logos from Wikimedia Commons' hotel logo category
  • Handles HTML encoded filenames
  • Includes error handling and logging
  • Respects Wikimedia's rate limits with random delays between requests
  • Creates a convenient zip archive of all downloaded logos

Notes

  • The script uses a custom User-Agent string to identify itself
  • It includes random delays between requests to be respectful to Wikimedia's servers
  • All downloaded files are saved in SVG format
  • The script includes comprehensive logging to track progress and any issues

Error Handling

The script includes error handling for:

  • Network issues
  • Missing or invalid SVG links
  • File download failures
  • File system operations

All errors are logged to the console for debugging purposes.

Troubleshooting

macOS Specific Issues

If you see an "externally-managed-environment" error:

  1. Make sure you're using a virtual environment
  2. Never use sudo with pip
  3. If you accidentally installed packages globally, you can remove them with:
    pip uninstall requests beautifulsoup4 urllib3
  4. Then follow the installation instructions above using a virtual environment

General Issues

If you encounter a ModuleNotFoundError when running the script:

  1. Make sure you have activated your virtual environment (you should see (venv) at the start of your command prompt)
  2. Verify the packages are installed by running:
    pip list
  3. If packages are missing, run the installation command again:
    pip install requests beautifulsoup4 urllib3

Common macOS Issues

  1. If you get a "command not found" error for python3:

    brew install python
  2. If you get permission errors:

    • Never use sudo with pip
    • Make sure you're using a virtual environment
    • Check that you have write permissions in the project directory
  3. If you need to start over:

    # Deactivate the virtual environment
    deactivate
    # Remove the old virtual environment
    rm -rf venv
    # Create a new one
    python3 -m venv venv
    # Activate it
    source venv/bin/activate
    # Install packages
    pip install requests beautifulsoup4 urllib3

About

Downloads the hotel logos from the WIKI site and places them in a ZIP file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages