File size: 529 Bytes
8ae7c70 31620dd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
---
license: apache-2.0
---
import requests
import shutil
data = 'https://api-ninjas.com'
fmt = 'png'
api_url = 'https://api.api-ninjas.com/v1/qrcode?data={}&format={}'.format(data, fmt)
response = requests.get(api_url, headers={'X-Api-Key': 'bYncBDuv5luV+rK7sqjemg==SAr2kbX5ZNqKmW8M
', 'Accept': 'image/png'}, stream=True)
if response.status_code == requests.codes.ok:
with open('img.jpg', 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
else:
print("Error:", response.status_code, response.text) |