This Python script generates a QR code image from a provided URL. It removes special characters from the URL to ensure compatibility with various file systems while still maintaining relevant information.
Features:
- Generates QR codes from URLs
- Handles invalid URLs gracefully
- Saves QR code as a PNG image
- Saves QR code as an SVG image
- Creates filename with URL information, removing special characters
Usage:
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS and Linux:
source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the script:
python main.py
You will be prompted to enter a URL.
-
Enter a valid URL and press Enter.
The script will generate and save the QR code image with a descriptive filename based on the URL.
Example:
If you enter the URL "https://hashir.blog", the script will generate files named "qr_code_hashir_blog.png" and "qr_code_hashir_blog.svg".
Requirements:
- Python 3.x
- Libraries:
- qrcode
- requests
- Pillow
- svgwrite