Created
November 2, 2020 13:07
-
-
Save lgsantiago/291786b3aa8e91b55e18cb9a3dfe371a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from selenium import webdriver | |
| import credentials | |
| import time | |
| from PIL import Image | |
| # Navigate to Wodify | |
| chrome_driver = webdriver.Chrome() | |
| chrome_driver.implicitly_wait(10) | |
| chrome_driver.get("https://app.wodify.com") | |
| # Sign in to Wodify | |
| chrome_driver.find_element_by_id("Input_UserName").send_keys(credentials.user_name) | |
| chrome_driver.find_element_by_id("Input_Password").send_keys(credentials.wod_password) | |
| chrome_driver.\ | |
| find_element_by_css_selector("#FormLogin > div.LoginWrapper.text-shade2 > div:nth-child(5) > button")\ | |
| .click() | |
| # Capture Image | |
| time.sleep(3) | |
| image_file = 'screenshots/screenshot.png' | |
| chrome_driver.save_screenshot(image_file) | |
| # Get location of element to crop screenshot | |
| element = chrome_driver.find_element_by_id("AthleteTheme_wtLayoutNormal_block_wtMainContent") | |
| location = element.location | |
| size = element.size | |
| # Crop image | |
| x = location['x'] | |
| y = location['y'] | |
| width = location['x']+size['width'] | |
| height = location['y']+size['height'] | |
| image = Image.open(image_file) | |
| image = image.crop((int(x), int(y), int(width), int(height))) | |
| image.save(image_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment