Uses webscraping to take and url and create a label for the bottle.
My parent make labels for their wine bottles to know what the wine fits with and what it contains and some other information. This program automates this process.
The py installer spec was created with:
pyi-makespec Systembolaget_Label.py --onefile
To create the executable run the following command in the src folder:
pyinstaller --clean Systembolaget_Label.spec
--clean ensures all temporary files and caches are removed before building the executable.
It takes URL's in an input.txt (creates it if missing) and sorts the real URL's with regular expressions. These validated URLs are then fetched with selenium, and then parsed with beautifulsoup4 for the data which is put into a wine class. It is then written to and output.txt and output.docx file.
Code was formated by python black. Python-docx for creating the word document for print out ontop of output.txt Uses selenium to scrape it since it allows for running of the Javascript to populate the page. The site is based on Next Js.Uses the built-in html parser.
We test with three wines to catch most cases.
256601 for a wine without full name.
225701 a wine with multiple bottle types.
626301 wine with higher price and diffrent location data, non integer alcohol procentage.
This uses the chromium webdriver because the firefox one has alot of small edges and versions which are incompatible with selenium. Thus using the chromium webdriver I saved alot of time and effort. It quite frankly seems like the chromium one is getting all the attantion and developer time. The webdriver is downloaded and handled by the webdriver managment library. For a manual set up get the lastest chromium driver download it here
Add GUI
Split out constants
Create tests
Consider adding python black in with a github action