From ccd2c49e39817705b3942c8623ee415ab41feea6 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 11 Mar 2022 20:44:21 +0100 Subject: [PATCH 01/10] zuschneiden der Screenshots implementiert. --- Main.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Main.py b/Main.py index 933b74a..4ad94fd 100644 --- a/Main.py +++ b/Main.py @@ -26,6 +26,7 @@ outputtext = "Welcome to application Sonnendach\n" columnIndexes = [] + def search_adresses(adress_list, filename_adresslist, driver): global file_split_char global stopThread @@ -75,20 +76,20 @@ def search_adresses(adress_list, filename_adresslist, driver): adress_file.write(new_adress_list) adress_file.close() - - - #featureElement = driver.find_element(By.XPATH, "// section[contains(string(),’START SCREENSHOT TESTING’)]") - #location = featureElement.location - #size = featureElement.size + featureElement = driver.find_element(By.XPATH, + "//section[@id='one']//div[@class='container']//div[@class='row 150%']") + location = featureElement.location + size = featureElement.size driver.save_screenshot(image_filename) - #x = location["x"] - #y = location["y"] - #w = x + size["width"] - #h = y + size["height"] - #fullImg = Image.open(image_filename) - #cropImg = fullImg.crop(x, y, w, h) - #cropImg.save(image_filename) - # TODO Screenshot schneiden + x = location["x"] + y = 0 # location["y"] + w = x + size["width"] + h = y + size["height"] - 100 + area = (x, y, w, h) + print(area) + fullImg = Image.open(image_filename) + cropImg = fullImg.crop(area) + cropImg.save(image_filename) print(image_filename + " was saved.") -- 2.40.1 From e0f4d585dfd316d5834a58a09013ab21bbb77acc Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 11 Mar 2022 21:39:01 +0100 Subject: [PATCH 02/10] created Version 1.2 --- Main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Main.py b/Main.py index 4ad94fd..3f741d5 100644 --- a/Main.py +++ b/Main.py @@ -6,6 +6,7 @@ from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from PIL import Image +import os from tkinter import filedialog import time @@ -32,6 +33,8 @@ def search_adresses(adress_list, filename_adresslist, driver): global stopThread global columnIndexes + if(not os.path.exists("screenshots")): + os.makedirs("screenshots", exist_ok=False) for i in range(len(adress_list)): line = adress_list[i] -- 2.40.1 From 1ce1657a654e03e41cac30db5f6fa86c5976abd7 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 11 Mar 2022 22:18:02 +0100 Subject: [PATCH 03/10] implemented qr-Code --- Main.py | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/Main.py b/Main.py index 3f741d5..9df01c4 100644 --- a/Main.py +++ b/Main.py @@ -7,12 +7,12 @@ from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from PIL import Image import os - +import qrcode from tkinter import filedialog import time -DropDownLabels = ["Street: ", "Number: ", "Postal code: ", "City: ", "Sonnendach URL: ", "Eignung", "Screenshot Filename: "] +DropDownLabels = ["Street: ", "Number: ", "Postal code: ", "City: ", "Sonnendach URL: ", "Eignung", "Screenshot Filename: ", "PV Production 50", "PV Production 75", "PV Production 100", "Value Electricity production"] file_split_char = "," OptionList = [] exit = False @@ -35,6 +35,8 @@ def search_adresses(adress_list, filename_adresslist, driver): if(not os.path.exists("screenshots")): os.makedirs("screenshots", exist_ok=False) + if (not os.path.exists("qrcodes")): + os.makedirs("qrcodes", exist_ok=False) for i in range(len(adress_list)): line = adress_list[i] @@ -62,11 +64,22 @@ def search_adresses(adress_list, filename_adresslist, driver): time.sleep(2) url = driver.current_url eignung = driver.find_element(By.ID, "eignung") - image_filename = "screenshots/" + eignung.text + " - " + search_string + ".png" + image_filename = eignung.text + " - " + search_string + ".png" + pv_Production50 = "50" + pv_Production75 = "75" + pv_Production100 = "100" + value_electricity_production = "value" adress[columnIndexes[4]] = url adress[columnIndexes[5]] = eignung.text adress[columnIndexes[6]] = image_filename + adress[columnIndexes[7]] = pv_Production50 + adress[columnIndexes[8]] = pv_Production75 + adress[columnIndexes[9]] = pv_Production100 + adress[columnIndexes[10]] = value_electricity_production + + + adress_file = open(filename_adresslist, "w") new_line_string = "" @@ -79,20 +92,25 @@ def search_adresses(adress_list, filename_adresslist, driver): adress_file.write(new_adress_list) adress_file.close() - featureElement = driver.find_element(By.XPATH, - "//section[@id='one']//div[@class='container']//div[@class='row 150%']") + #Create Screenshot + featureElement = driver.find_element(By.XPATH, "//section[@id='one']//div[@class='container']//div[@class='row 150%']") location = featureElement.location size = featureElement.size - driver.save_screenshot(image_filename) + driver.save_screenshot("screenshots/" + image_filename) x = location["x"] y = 0 # location["y"] w = x + size["width"] h = y + size["height"] - 100 area = (x, y, w, h) - print(area) - fullImg = Image.open(image_filename) + fullImg = Image.open("screenshots/" + image_filename) cropImg = fullImg.crop(area) - cropImg.save(image_filename) + cropImg.save("screenshots/" + image_filename) + + #Create QR-Code + qr = qrcode.QRCode(version=1, box_size=10, border=5) + qr.add_data(url) + qr.make(fit=True) + qr.make_image(fill='black', back_color='white').save("qrcodes/" + image_filename) print(image_filename + " was saved.") -- 2.40.1 From d75177f7be51a19ebd87420c7de820ba8afc3ad8 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 11 Mar 2022 22:18:40 +0100 Subject: [PATCH 04/10] implemented qr-Code --- Main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Main.py b/Main.py index 9df01c4..ab2ea33 100644 --- a/Main.py +++ b/Main.py @@ -12,7 +12,7 @@ from tkinter import filedialog import time -DropDownLabels = ["Street: ", "Number: ", "Postal code: ", "City: ", "Sonnendach URL: ", "Eignung", "Screenshot Filename: ", "PV Production 50", "PV Production 75", "PV Production 100", "Value Electricity production"] +DropDownLabels = ["Street: ", "Number: ", "Postal code: ", "City: ", "Sonnendach URL: ", "Eignung", "Image Filename: ", "PV Production 50", "PV Production 75", "PV Production 100", "Value Electricity production"] file_split_char = "," OptionList = [] exit = False -- 2.40.1 From 1a0e75fe3c4f22e9654241c4bf7832b602fab310 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 11 Mar 2022 23:13:11 +0100 Subject: [PATCH 05/10] implemented pv_Production and value_electricity_production --- Main.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Main.py b/Main.py index ab2ea33..6cf2164 100644 --- a/Main.py +++ b/Main.py @@ -64,19 +64,21 @@ def search_adresses(adress_list, filename_adresslist, driver): time.sleep(2) url = driver.current_url eignung = driver.find_element(By.ID, "eignung") + pv_Production50 = driver.find_element(By.ID, "pv50") + pv_Production75 = driver.find_element(By.ID, "pv75") + pv_Production100 = driver.find_element(By.ID, "pv100") + value_electricity_production = driver.find_elements(By.XPATH, "//h2[@id='TitelSolarstrom']//strong")[2] + image_filename = eignung.text + " - " + search_string + ".png" - pv_Production50 = "50" - pv_Production75 = "75" - pv_Production100 = "100" - value_electricity_production = "value" adress[columnIndexes[4]] = url adress[columnIndexes[5]] = eignung.text adress[columnIndexes[6]] = image_filename - adress[columnIndexes[7]] = pv_Production50 - adress[columnIndexes[8]] = pv_Production75 - adress[columnIndexes[9]] = pv_Production100 - adress[columnIndexes[10]] = value_electricity_production + # TODO: 1000er Trennzeichen und " Franken" entfernen + adress[columnIndexes[7]] = pv_Production50.text + adress[columnIndexes[8]] = pv_Production75.text + adress[columnIndexes[9]] = pv_Production100.text + adress[columnIndexes[10]] = value_electricity_production.text -- 2.40.1 From aaad6a5b070d00c8d492e7a8087650db1da35684 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Fri, 11 Mar 2022 23:46:36 +0100 Subject: [PATCH 06/10] entfernen von 1000er Trennzeichen und " Franken" --- Main.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Main.py b/Main.py index 6cf2164..722a829 100644 --- a/Main.py +++ b/Main.py @@ -56,12 +56,11 @@ def search_adresses(adress_list, filename_adresslist, driver): if(suggestion.text == search_string): found = True suggestion.click() - driver.implicitly_wait(120) + driver.implicitly_wait(10) break if(found): - - time.sleep(2) + # TODO: Validation url = driver.current_url eignung = driver.find_element(By.ID, "eignung") pv_Production50 = driver.find_element(By.ID, "pv50") @@ -75,10 +74,10 @@ def search_adresses(adress_list, filename_adresslist, driver): adress[columnIndexes[5]] = eignung.text adress[columnIndexes[6]] = image_filename # TODO: 1000er Trennzeichen und " Franken" entfernen - adress[columnIndexes[7]] = pv_Production50.text - adress[columnIndexes[8]] = pv_Production75.text - adress[columnIndexes[9]] = pv_Production100.text - adress[columnIndexes[10]] = value_electricity_production.text + adress[columnIndexes[7]] = pv_Production50.text.replace("'", "") + adress[columnIndexes[8]] = pv_Production75.text.replace("'", "") + adress[columnIndexes[9]] = pv_Production100.text.replace("'", "") + adress[columnIndexes[10]] = value_electricity_production.text.replace("'", "").replace(" Franken", "") @@ -94,25 +93,26 @@ def search_adresses(adress_list, filename_adresslist, driver): adress_file.write(new_adress_list) adress_file.close() + # Create QR-Code + qr = qrcode.QRCode(version=1, box_size=10, border=5) + qr.add_data(url) + qr.make(fit=True) + qr.make_image(fill='black', back_color='white').save("qrcodes/" + image_filename) + #Create Screenshot featureElement = driver.find_element(By.XPATH, "//section[@id='one']//div[@class='container']//div[@class='row 150%']") location = featureElement.location size = featureElement.size - driver.save_screenshot("screenshots/" + image_filename) x = location["x"] y = 0 # location["y"] w = x + size["width"] h = y + size["height"] - 100 area = (x, y, w, h) - fullImg = Image.open("screenshots/" + image_filename) - cropImg = fullImg.crop(area) - cropImg.save("screenshots/" + image_filename) + time.sleep(2) + driver.save_screenshot("screenshots/" + image_filename) + time.sleep(0.2) + Image.open("screenshots/" + image_filename).crop(area).save("screenshots/" + image_filename) - #Create QR-Code - qr = qrcode.QRCode(version=1, box_size=10, border=5) - qr.add_data(url) - qr.make(fit=True) - qr.make_image(fill='black', back_color='white').save("qrcodes/" + image_filename) print(image_filename + " was saved.") -- 2.40.1 From c1be042b9a496b137e102a6b49898e06dd545d32 Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Sun, 13 Mar 2022 08:06:03 +0100 Subject: [PATCH 07/10] changed timesleep, because wrong urls are saved --- Main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Main.py b/Main.py index 722a829..8c13fc2 100644 --- a/Main.py +++ b/Main.py @@ -60,6 +60,7 @@ def search_adresses(adress_list, filename_adresslist, driver): break if(found): + time.sleep(2) # TODO: Validation url = driver.current_url eignung = driver.find_element(By.ID, "eignung") @@ -108,7 +109,7 @@ def search_adresses(adress_list, filename_adresslist, driver): w = x + size["width"] h = y + size["height"] - 100 area = (x, y, w, h) - time.sleep(2) + time.sleep(1) driver.save_screenshot("screenshots/" + image_filename) time.sleep(0.2) Image.open("screenshots/" + image_filename).crop(area).save("screenshots/" + image_filename) -- 2.40.1 From 768da6c14f4f8b60ba085ca6944f5e5391e91a3f Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Sun, 13 Mar 2022 16:58:40 +0100 Subject: [PATCH 08/10] =?UTF-8?q?Problembehebung=20Funktionalit=C3=A4t=20"?= =?UTF-8?q?erledigte=20=C3=BCberspringen"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Main.py b/Main.py index 8c13fc2..25d6022 100644 --- a/Main.py +++ b/Main.py @@ -41,7 +41,7 @@ def search_adresses(adress_list, filename_adresslist, driver): for i in range(len(adress_list)): line = adress_list[i] adress = line.split(file_split_char) - if((line != adress_list[0]) & ((adress[20][0:11] != "screenshots"))): + if((line != adress_list[0]) & ((adress[columnIndexes[6]] == ""))): print(adress) search_string = adress[columnIndexes[0]] + " " + adress[columnIndexes[1]] + " " + adress[columnIndexes[2]] + " " + adress[columnIndexes[3]] search_bar = driver.find_element(By.ID, "searchTypeahead1") -- 2.40.1 From 34c3023cf95dc3d6109c41900e9b9b2576680f3a Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Sun, 13 Mar 2022 17:14:09 +0100 Subject: [PATCH 09/10] Zuschneiden der Screenshots angepasst. --- Main.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Main.py b/Main.py index 25d6022..a301bdc 100644 --- a/Main.py +++ b/Main.py @@ -100,14 +100,18 @@ def search_adresses(adress_list, filename_adresslist, driver): qr.make(fit=True) qr.make_image(fill='black', back_color='white').save("qrcodes/" + image_filename) - #Create Screenshot - featureElement = driver.find_element(By.XPATH, "//section[@id='one']//div[@class='container']//div[@class='row 150%']") - location = featureElement.location - size = featureElement.size + # Create Screenshot + featureElement1 = driver.find_element(By.XPATH, + "//section[@id='one']//div[@class='container']//div[@class='row 150%']") + featureElement2 = driver.find_element(By.XPATH, + "//section[@id='one']") + location = featureElement1.location + size1 = featureElement1.size + size2 = featureElement2.size x = location["x"] - y = 0 # location["y"] - w = x + size["width"] - h = y + size["height"] - 100 + y = 5 # location["y"] + w = x + size2["width"] + h = y + size1["height"] area = (x, y, w, h) time.sleep(1) driver.save_screenshot("screenshots/" + image_filename) -- 2.40.1 From 4b11d0e4def98b7ca45976aa64c9b5085ec53f2a Mon Sep 17 00:00:00 2001 From: romanschenk37 <84532681+romanschenk37@users.noreply.github.com> Date: Tue, 15 Mar 2022 08:14:51 +0100 Subject: [PATCH 10/10] =?UTF-8?q?Event=20EM=5FDELETE=5FWINDOWS=20hinzugef?= =?UTF-8?q?=C3=BCgt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Main.py b/Main.py index a301bdc..cbd0d98 100644 --- a/Main.py +++ b/Main.py @@ -248,6 +248,7 @@ def command_exit(): root = tkinter.Tk() +root.protocol("WM_DELETE_WINDOW", command_exit) root.wm_title("Sonnendach") mainText = tkinter.Label(root, text=outputtext, width=80) mainText.grid(row=1, column=1, padx=10, pady=3) -- 2.40.1