41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
import math
|
|
from io import BytesIO
|
|
from time import sleep
|
|
import os
|
|
|
|
from PIL import Image
|
|
from selenium import webdriver
|
|
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.common.action_chains import ActionChains
|
|
|
|
class YandexMap:
|
|
def __init__(self):
|
|
options = webdriver.ChromeOptions()
|
|
# options.add_experimental_option("detach", True)
|
|
self.driver = webdriver.Chrome(options)
|
|
self.driver.get("https://yandex.ru/maps/43/kazan/?ll=49.103814%2C55.794258&z=10")
|
|
sleep(5)
|
|
|
|
action = ActionChains(self.driver)
|
|
|
|
# Закрытие левой панели
|
|
action.click(self.driver.find_element(By.CLASS_NAME, 'sidebar-toggle-button'))
|
|
action.move_to_element_with_offset(self.driver.find_element(By.XPATH, "//div[@class='rounded-controls']/div[@class='rounded-controls__child'][5]//button"), 5, 5)
|
|
action.perform()
|
|
|
|
# Режим спутника
|
|
action.click(self.driver.find_element(By.CLASS_NAME, '_key_satellite'))
|
|
action.perform()
|
|
|
|
html = self.driver.find_element(By.TAG_NAME, 'html')
|
|
action.move_to_element_with_offset(html, 200, 200)
|
|
action.perform()
|
|
|
|
sleep(5)
|
|
|
|
def savePhoto(self, filename: str) -> bytes:
|
|
return self.driver.save_screenshot(filename)
|
|
|
|
def destroy(self):
|
|
self.driver.close()
|