Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save walkingpendulum/c005c904f1c4ce548ffba10130be2f22 to your computer and use it in GitHub Desktop.
Save walkingpendulum/c005c904f1c4ce548ffba10130be2f22 to your computer and use it in GitHub Desktop.
{
"type": "FeatureCollection",
"metadata": {
"name": "rent 2021",
"creator": "Yandex Map Constructor"
},
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.659867,
55.813325
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/236384923/>2-\u043a\u043e\u043c\u043d. \u043a\u0432., 72\u00a0\u043c\u00b2, 5/8 \u044d\u0442\u0430\u0436\n55\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u0420\u0438\u0436\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0435\u0437\u0434, 5",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.527427,
55.839495
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/259077559/>2-\u043a\u043e\u043c\u043d. \u043a\u0432., 59\u00a0\u043c\u00b2, 21/22 \u044d\u0442\u0430\u0436\n55\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u041c\u0438\u0445\u0430\u043b\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u0443\u043b\u0438\u0446\u0430, 15\u043a1",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.579175,
55.82352
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/259374398/>2-\u043a\u043e\u043c\u043d. \u043a\u0432., 57\u00a0\u043c\u00b2, 7/9 \u044d\u0442\u0430\u0436\n55\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u0443\u043b\u0438\u0446\u0430 \u042f\u0431\u043b\u043e\u0447\u043a\u043e\u0432\u0430, 29",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.585895,
55.815209
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/257490833/>3-\u043a\u043e\u043c\u043d. \u043a\u0432., 65\u00a0\u043c\u00b2, 4/12 \u044d\u0442\u0430\u0436\n55\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u0443\u043b\u0438\u0446\u0430 \u0413\u043e\u043d\u0447\u0430\u0440\u043e\u0432\u0430, 13\u041a1",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.661257,
55.829152
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/259255324/>3-\u043a\u043e\u043c\u043d. \u043a\u0432., 60\u00a0\u043c\u00b2, 7/9 \u044d\u0442\u0430\u0436\n50\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u043f\u0440\u043e\u0435\u0437\u0434 \u041a\u0430\u0434\u043e\u043c\u0446\u0435\u0432\u0430, 5\u041a2",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.659923,
55.856153
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/259088901/>2-\u043a\u043e\u043c\u043d. \u043a\u0432., 61\u00a0\u043c\u00b2, 15/17 \u044d\u0442\u0430\u0436\n50\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u043f\u0440\u043e\u0435\u0437\u0434 \u0411\u0435\u0440\u0438\u043d\u0433\u043e\u0432, 3",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.592678,
55.873447
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/165688199/>3-\u043a\u043e\u043c\u043d. \u043a\u0432., 80\u00a0\u043c\u00b2, 13/22 \u044d\u0442\u0430\u0436\n50\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u0412\u044b\u0441\u043e\u043a\u043e\u0432\u043e\u043b\u044c\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u0437\u0434, 1\u043a6",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.51993,
55.815859
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/200119744/>2-\u043a\u043e\u043c\u043d. \u043a\u0432., 55\u00a0\u043c\u00b2, 9/14 \u044d\u0442\u0430\u0436\n55\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u0443\u043b\u0438\u0446\u0430 \u041a\u043e\u0441\u043c\u043e\u043d\u0430\u0432\u0442\u0430 \u0412\u043e\u043b\u043a\u043e\u0432\u0430, 29\u041a1",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.650796,
55.812966
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/258075254/>2-\u043a\u043e\u043c\u043d. \u043a\u0432., 62\u00a0\u043c\u00b2, 10/17 \u044d\u0442\u0430\u0436\n51\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u041c\u0430\u043b\u043e\u043c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0430\u044f \u0443\u043b\u0438\u0446\u0430, 21\u041a1",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.503705,
55.823612
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/258856221/>1-\u043a\u043e\u043c\u043d. \u043a\u0432., 56\u00a0\u043c\u00b2, 12/16 \u044d\u0442\u0430\u0436\n50\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u0421\u0442\u0430\u0440\u043e\u043f\u0435\u0442\u0440\u043e\u0432\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0435\u0437\u0434, 12\u043a4",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.576925,
55.829251
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/248501439/>3-\u043a\u043e\u043c\u043d. \u043a\u0432., 75\u00a0\u043c\u00b2, 2/24 \u044d\u0442\u0430\u0436\n50\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u0443\u043b\u0438\u0446\u0430 \u042f\u0431\u043b\u043e\u0447\u043a\u043e\u0432\u0430, 45",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.537615,
55.839583
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/259153892/>3-\u043a\u043e\u043c\u043d. \u043a\u0432., 65\u00a0\u043c\u00b2, 16/16 \u044d\u0442\u0430\u0436\n45\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": "\u0439 \u041d\u043e\u0432\u043e\u043c\u0438\u0445\u0430\u043b\u043a\u043e\u0432\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0435\u0437\u0434, 8\u041a1",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.661205,
55.838101
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/259125590/>2-\u043a\u043e\u043c\u043d. \u043a\u0432., 70\u00a0\u043c\u00b2, 3/5 \u044d\u0442\u0430\u0436\n55\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": " \u043f\u0440\u043e\u0441\u043f\u0435\u043a\u0442 \u041c\u0438\u0440\u0430, 200",
"marker-color": "#1e98ff"
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.656312,
55.811485
]
},
"properties": {
"description": "<a target=\"_blank\" rel=\"noopener noreferrer\" href=https://www.cian.ru/rent/flat/243111551/>2-\u043a\u043e\u043c\u043d. \u043a\u0432., 60\u00a0\u043c\u00b2, 6/8 \u044d\u0442\u0430\u0436\n53\u00a0000\u00a0\u20bd/\u043c\u0435\u0441.</a>",
"iconCaption": "\u0439 \u0420\u0438\u0436\u0441\u043a\u0438\u0439 \u043f\u0435\u0440\u0435\u0443\u043b\u043e\u043a, 3",
"marker-color": "#1e98ff"
}
}
]
}
import os
import pathlib
from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
def make_driver(headless: bool = True) -> WebDriver:
chrome_options = ChromeOptions()
if headless:
chrome_options.add_argument("--headless")
return webdriver.Chrome(options=chrome_options)
def authorize_at_ya(username: str, password: str, driver: WebDriver) -> None:
driver.get("https://passport.yandex.ru/auth")
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "passp-field-login"))).send_keys(username)
driver.find_element_by_xpath('//button[normalize-space()="Войти"]').click()
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "passp-field-passwd"))).send_keys(password)
driver.find_element_by_xpath('//button[normalize-space()="Войти"]').click()
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "ProfileTile")))
if __name__ == '__main__':
driver = make_driver(headless=not bool(os.getenv('DISABLE_HEADLESS')))
username, password = os.environ["USERNAME"], os.environ["PASSWORD"]
authorize_at_ya(username=username, password=password, driver=driver)
driver.get("https://yandex.ru/map-constructor/")
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "button_id_import-button"))).click()
file_path = str(pathlib.Path("./map.geojson").resolve())
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@type='file']"))).send_keys(file_path)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "button_id_saveBtn"))).click()
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "button_id_get-code-btn"))).click()
element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "textarea_id_code-preview")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment