How do I generate a qr code which when scanned opens a url? is it possible to use a library like qrcode or pyqrcode to accomplish this?
something like this :
pyq = QRCode()
pyq.generate(url="http://google.com/")
How do I generate a qr code which when scanned opens a url? is it possible to use a library like qrcode or pyqrcode to accomplish this?
something like this :
pyq = QRCode()
pyq.generate(url="http://google.com/")
Yes you can use qrcode:
import qrcode
import qrcode.image.svg
img = qrcode.make('http://www.google.com/', image_factory=qrcode.image.svg.SvgImage)
with open('qr.svg', 'wb') as qr:
img.save(qr)
You can use google apis to create qr code without additional library:
import requests
WIDTH = 400
HEIGHT = 400
DATA = "http://www.google.com/"
image = requests.get(f"https://chart.googleapis.com/chart?chs={WIDTH}x{HEIGHT}&cht=qr&chl={DATA}")
image.raise_for_status()
with open("qr.png", "wb") as qr:
qr.write(image.content)
© 2022 - 2024 — McMap. All rights reserved.