Files
Nuliga2/.ipynb_checkpoints/QR_parser-checkpoint.ipynb
T
2025-08-31 14:51:45 +02:00

4.1 KiB

In [6]:
#import requests
#import re
#from bs4 import BeautifulSoup
import qrcode
from PIL import Image, ImageDraw, ImageFont
    
#teamlinks = [[0 for x in range(3)] for y in range(17)]
teamlinks=[]
teamlinks.append(['1. Herren', 'https://www.esg-handball.de/teams/teammatches/90', 'H1'])
teamlinks.append(['1. Damen', 'https://www.esg-handball.de/teams/teammatches/12', 'D1'])
teamlinks.append(['2. Herren', 'https://www.esg-handball.de/teams/teammatches/2', 'H2'])
teamlinks.append(['2. Damen', 'https://www.esg-handball.de/teams/teammatches/39', 'D2'])
teamlinks.append(['3. Herren', 'https://www.esg-handball.de/teams/teammatches/48', 'H3'])
teamlinks.append(['4. Herren', 'https://www.esg-handball.de/teams/teammatches/11', 'H4'])
teamlinks.append(['5. Herren', 'https://www.esg-handball.de/teams/teammatches/80', 'H5'])
#teamlinks.append(['mA-Jugend', 'https://www.esg-handball.de/teams/teammatches/5', 'mA'])
teamlinks.append(['mB-Jugend', 'https://www.esg-handball.de/teams/teammatches/77', 'mB'])
teamlinks.append(['wB-Jugend', 'https://www.esg-handball.de/teams/teammatches/17', 'wB'])  
teamlinks.append(['mC-Jugend', 'https://www.esg-handball.de/teams/teammatches/78', 'mC'])
teamlinks.append(['mC2-Jugend', 'https://www.esg-handball.de/teams/teammatches/14', 'mC2'])
#teamlinks.append(['wC-Jugend', 'https://www.esg-handball.de/teams/teammatches/16', 'wC'])
teamlinks.append(['gJD-Jugend', 'https://www.esg-handball.de/teams/teammatches/6', 'gJD'])
teamlinks.append(['gJD-Jugend', 'https://www.esg-handball.de/teams/teammatches/20', 'gJD2'])
teamlinks.append(['wd-Jugend', 'https://www.esg-handball.de/teams/teammatches/15', 'wD'])
teamlinks.append(['gJE-Jugend', 'https://www.esg-handball.de/teams/teammatches/7', 'gJE'])
teamlinks.append(['gJE-Jugend', 'https://www.esg-handball.de/teams/teammatches/20', 'gJE2'])
teamlinks.append(['gJE-Jugend', 'https://www.esg-handball.de/teams/teammatches/87', 'gJE3'])
teamlinks.append(['F-Jugend', 'https://www.esg-handball.de/teams/teammatches/8', 'F'])
teamlinks.append(['F-Jugend 2', 'https://www.esg-handball.de/teams/teammatches/64', 'F2'])
teamlinks.append(['Minis', 'https://www.esg-handball.de/teams/current/34', 'Mi'])
  



def gen_qrcode(name, link):
	img_bg = Image.new('RGB', (135, 70), color = (0,0,0))
	fnt = ImageFont.truetype('/System/Library/Fonts/Supplemental/Arial Bold.ttf', 60)
	d = ImageDraw.Draw(img_bg)
	if len(name) == 3:
		d.text((5,3), name, font=fnt, fill=(255, 255, 255))
	else :
		d.text((25,3), name, font=fnt, fill=(255, 255, 255))
	qr = qrcode.QRCode(box_size=9,error_correction=qrcode.constants.ERROR_CORRECT_H)
	qr.add_data(link)
	qr.make()
	img_qr = qr.make_image()

	pos = (int((img_qr.size[0] - img_bg.size[0])/2), int((img_qr.size[1] - img_bg.size[1])/2))

	img_qr.paste(img_bg, pos)
	img_qr.save(name+'.png')
		
#teamlinks.pop()
#teamlinks[len(teamlinks)-1][2]='F'
for team in (teamlinks):
	gen_qrcode(team[2],team[1])
In [ ]: