Created
September 16, 2023 22:24
-
-
Save deepcoder/e9aee1209faf9f6a7f40ba7c05d5a541 to your computer and use it in GitHub Desktop.
blitzortung lighting map image capture
This file contains 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
#! /usr/bin/env python3 | |
# blitzortung_capture.py | |
from selenium import webdriver | |
from selenium.webdriver.firefox.options import Options | |
from PIL import Image | |
options = Options() | |
options.add_argument("--headless") | |
# options.headless = True | |
browser = webdriver.Firefox(options=options) | |
browser.set_window_size(920, 1080) # Set the window size (width, height) | |
url = "https://www.blitzortung.org/en/live_lightning_maps.php?map=35" # Replace with the actual URL | |
browser.get(url) | |
# Wait for the page to load | |
browser.implicitly_wait(10) | |
# Find the "Accept all" button by its onclick attribute and click it | |
# accept_all_button = browser.find_element_by_xpath("//span[text()='Accept all']") | |
accept_all_button = browser.find_element("xpath", "//span[text()='Accept all']") | |
accept_all_button.click() | |
# Take a screenshot | |
#browser.save_screenshot("/media/nas01-v00/Dropbox/0-blitzortung_capture/blitzortung_capture.png") | |
browser.save_screenshot("/tmp/blitzortung_capture.png") | |
browser.quit() | |
im = Image.open("/tmp/blitzortung_capture.png") | |
width, height = im.size | |
print(width, height) | |
# Setting the points for cropped image | |
left = 0 | |
top = 300 | |
right = width | |
bottom = height | |
im1 = im.crop((left, top, right, bottom)) | |
# im1 = im | |
im1.save("/media/nas01-v00/Dropbox/0-blitzortung_capture/blitzortung_capture.png") | |
# EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment