-
Notifications
You must be signed in to change notification settings - Fork 0
/
qr.py
48 lines (39 loc) · 1.19 KB
/
qr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import qrcode
import requests
print("""
__ __ ____
| \/ | _ \
| \ / | |_) |
| |\/| | _ <
| | | | |_) |
|_| |_|____/
======= Mansoor Barri =======
https://mansoorbarri.com
""")
def generate_qr_code(url, fill_color, output_file):
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=0,
)
qr.add_data(url)
qr.make(fit=True)
img = qr.make_image(fill_color="#9999d2", back_color="transparent")
img.save(output_file)
def main():
fill_color = input("Enter the color reference number (e.g., #ffffff) for the fill color: ")
while True:
url = input("Enter the URL: ").strip()
try:
response = requests.head(url)
if response.status_code == 200:
break
else:
print("Error: URL is not accessible. Please enter a valid URL.")
except Exception as e:
print(f"Error: {e}")
output_file = input("Enter the destination file name (with .png extension): ")
generate_qr_code(url, fill_color, output_file)
if __name__ == "__main__":
main()