{"id":322123,"date":"2021-04-26T15:02:04","date_gmt":"2021-04-26T15:02:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=322123"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=322123","title":{"rendered":"\u0413\u043e\u0441\u0443\u0441\u043b\u0443\u0433\u0438 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u043d\u0430 \u043f\u0440\u0438\u0435\u043c. \u0416\u0438\u0432\u0430\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044c?"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0432\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0440\u0438\u0435\u043c, \u0430 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0442\u0430\u043b\u043e\u043d\u043e\u0432 \u043d\u0435\u0442. \u0421\u0442\u0430\u0442\u044c\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0433\u0440\u0430\u043d\u043f\u0430\u0441\u043f\u043e\u0440\u0442\u0430.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u0434\u043e\u0431\u0440\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0437\u0430\u0433\u0440\u0430\u043d\u043f\u0430\u0441\u043f\u043e\u0440\u0442, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043b\u0438\u0447\u043d\u043e\u0435 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043d\u0435\u0441\u0442\u0438 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u043e\u0442\u043e. \u0417\u0430\u0445\u043e\u0434\u044f \u043d\u0430 \u0433\u043e\u0441\u0443\u0441\u043b\u0443\u0433\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439 \u0432 \u0440\u0430\u0437\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0442\u0430\u043b\u043e\u043d\u043e\u0432 \u0442\u0430\u043a \u0438 \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u043e\u0441\u044c. \u041d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043b\u043e\u0442\u0435\u0440\u0435\u044e.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0430\u0434\u0440\u0435\u0441 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u044f. \u041e\u043d \u0432\u0438\u0434\u0435\u043d \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u041e\u0442\u0442\u0443\u0434\u0430 \u0443\u0437\u043d\u0430\u0435\u043c \u043e URL \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445. <\/p>\n<pre><code class=\"python\">def send_post(cookies):     url = 'https:\/\/www.gosuslugi.ru\/api\/lk\/v1\/equeue\/agg\/slots'     headers = {'Content-type': 'application\/json;charset=UTF-8', 'Accept':'application\/json', 'Cookie':cookies}     payload = {'eserviceId':'','serviceId':[''],'organizationId':[''],'parentOrderId':'','serviceCode':'','attributes':[]}     return post(url, data=dumps(payload), headers=headers)<\/code><\/pre>\n<p>\u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442, \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0443\u043a\u0438. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041d\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 (401) \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u043a\u0443\u043a\u0438, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u0438\u0445 \u0432 \u0444\u0430\u0439\u043b. \u041a\u043e\u0433\u0434\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430, \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cac\/c14\/e87\/cacc14e87fecd2c770e10297a3f20353.png\" width=\"1625\" height=\"1375\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0441\u044f Python, Selenium \u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0437\u0430\u0434\u0430\u043d\u0438\u0439 Windows. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">from webbrowser import open as open_tab from selenium import webdriver from datetime import datetime from requests import post from json import dumps from os import path  def main():     response = send_post(read_cookies())     if response.status_code == 401:         write_cookies(get_cookies())         write_log('\u041e\u0448\u0438\u0431\u043a\u0430 401. \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u043a\u0443\u043a\u0438.')         main()         return     elif response.status_code == 200:         length = len(response.json()['slots'])         if length &gt; 0:             write_log('\u0415\u0441\u0442\u044c \u043c\u0435\u0441\u0442: ' + length)             open_tab(TARGET_LINK, new=1)         else:              write_log('\u041d\u0435\u0442 \u043c\u0435\u0441\u0442')     else:         write_log('\u041e\u0448\u0438\u0431\u043a\u0430 {0}'.format(response.status_code))<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u0443\u043a\u0438, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Selenium \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432\u0445\u043e\u0434\u0430, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043b\u043e\u0433\u0438\u043d \u0441 \u043f\u0430\u0440\u043e\u043b\u0435\u043c. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u043e\u043a\u043e\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0437 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432 \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043e\u043a\u043d\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043d\u0430 \u043f\u0430\u0440\u0443 \u0441\u0435\u043a\u0443\u043d\u0434. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043a\u0443\u043a, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0433\u0434\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441 \u0432\u0435\u0434\u043e\u043c\u0441\u0442\u0432\u0430 <code>TARGET_LINK<\/code>.<\/p>\n<pre><code class=\"python\">def get_cookies():     options = webdriver.ChromeOptions()     options.add_argument('--no-sandbox')     options.add_argument('--minimal')      driver = webdriver.Chrome(executable_path=DRIVER_FILE, options=options)     driver.get('https:\/\/esia.gosuslugi.ru\/')     driver.implicitly_wait(7)      input_login = driver.find_element_by_id('login')     input_password = driver.find_element_by_id('password')     btn_enter = driver.find_element_by_id('loginByPwdButton')      input_login.send_keys(LOGIN)     input_password.send_keys(PASSWORD)     btn_enter.click()      driver.get(TARGET_LINK)     cookies = driver.get_cookies()     driver.close()     return cookies<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u0443\u043a\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 <code>\u0438\u043c\u044f=\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435;<\/code><\/p>\n<pre><code class=\"python\">raw_cookies = ''.join(['{}={}; '.format(i['name'], i['value']) for i in cookies])<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0437\u0430\u0434\u0430\u043d\u0438\u0439 Windows. \u041f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0430 <code>.py<\/code> \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 <code>.bat<\/code> \u043e\u0434\u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>python \"script.py\"<\/code>. \u0414\u0430, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043a\u043d\u043e \u043a\u043e\u043d\u0441\u043e\u043b\u0438. \u0415\u0441\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441\u043a\u0440\u044b\u0442\u043d\u043e.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043d\u0430 \u0442\u0440\u0435\u0442\u0438\u0439 \u0434\u0435\u043d\u044c \u0438 240 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u0432 \u0440\u0430\u0439\u043e\u043d\u0435 17 \u0447\u0430\u0441\u043e\u0432 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438. \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/554406\/\"> https:\/\/habr.com\/ru\/post\/554406\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0432\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0440\u0438\u0435\u043c, \u0430 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0442\u0430\u043b\u043e\u043d\u043e\u0432 \u043d\u0435\u0442. \u0421\u0442\u0430\u0442\u044c\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0433\u0440\u0430\u043d\u043f\u0430\u0441\u043f\u043e\u0440\u0442\u0430.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043e\u0434\u043e\u0431\u0440\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u0437\u0430\u0433\u0440\u0430\u043d\u043f\u0430\u0441\u043f\u043e\u0440\u0442, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043b\u0438\u0447\u043d\u043e\u0435 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043d\u0435\u0441\u0442\u0438 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u043e\u0442\u043e. \u0417\u0430\u0445\u043e\u0434\u044f \u043d\u0430 \u0433\u043e\u0441\u0443\u0441\u043b\u0443\u0433\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439 \u0432 \u0440\u0430\u0437\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0442\u0430\u043b\u043e\u043d\u043e\u0432 \u0442\u0430\u043a \u0438 \u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b\u043e\u0441\u044c. \u041d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043b\u043e\u0442\u0435\u0440\u0435\u044e.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0430\u0434\u0440\u0435\u0441 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u044f. \u041e\u043d \u0432\u0438\u0434\u0435\u043d \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u041e\u0442\u0442\u0443\u0434\u0430 \u0443\u0437\u043d\u0430\u0435\u043c \u043e URL \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445. <\/p>\n<pre><code class=\"python\">def send_post(cookies):     url = 'https:\/\/www.gosuslugi.ru\/api\/lk\/v1\/equeue\/agg\/slots'     headers = {'Content-type': 'application\/json;charset=UTF-8', 'Accept':'application\/json', 'Cookie':cookies}     payload = {'eserviceId':'','serviceId':[''],'organizationId':[''],'parentOrderId':'','serviceCode':'','attributes':[]}     return post(url, data=dumps(payload), headers=headers)<\/code><\/pre>\n<p>\u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442, \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0443\u043a\u0438. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041d\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 (401) \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u043a\u0443\u043a\u0438, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u0438\u0445 \u0432 \u0444\u0430\u0439\u043b. \u041a\u043e\u0433\u0434\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430, \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435. <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0441\u044f Python, Selenium \u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0437\u0430\u0434\u0430\u043d\u0438\u0439 Windows. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">from webbrowser import open as open_tab from selenium import webdriver from datetime import datetime from requests import post from json import dumps from os import path  def main():     response = send_post(read_cookies())     if response.status_code == 401:         write_cookies(get_cookies())         write_log('\u041e\u0448\u0438\u0431\u043a\u0430 401. \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u043a\u0443\u043a\u0438.')         main()         return     elif response.status_code == 200:         length = len(response.json()['slots'])         if length &gt; 0:             write_log('\u0415\u0441\u0442\u044c \u043c\u0435\u0441\u0442: ' + length)             open_tab(TARGET_LINK, new=1)         else:              write_log('\u041d\u0435\u0442 \u043c\u0435\u0441\u0442')     else:         write_log('\u041e\u0448\u0438\u0431\u043a\u0430 {0}'.format(response.status_code))<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u0443\u043a\u0438, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Selenium \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432\u0445\u043e\u0434\u0430, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043b\u043e\u0433\u0438\u043d \u0441 \u043f\u0430\u0440\u043e\u043b\u0435\u043c. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u043e\u043a\u043e\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0437 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432 \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043e\u043a\u043d\u043e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043d\u0430 \u043f\u0430\u0440\u0443 \u0441\u0435\u043a\u0443\u043d\u0434. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043a\u0443\u043a, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0433\u0434\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441 \u0432\u0435\u0434\u043e\u043c\u0441\u0442\u0432\u0430 <code>TARGET_LINK<\/code>.<\/p>\n<pre><code class=\"python\">def get_cookies():     options = webdriver.ChromeOptions()     options.add_argument('--no-sandbox')     options.add_argument('--minimal')      driver = webdriver.Chrome(executable_path=DRIVER_FILE, options=options)     driver.get('https:\/\/esia.gosuslugi.ru\/')     driver.implicitly_wait(7)      input_login = driver.find_element_by_id('login')     input_password = driver.find_element_by_id('password')     btn_enter = driver.find_element_by_id('loginByPwdButton')      input_login.send_keys(LOGIN)     input_password.send_keys(PASSWORD)     btn_enter.click()      driver.get(TARGET_LINK)     cookies = driver.get_cookies()     driver.close()     return cookies<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043a\u0443\u043a\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 <code>\u0438\u043c\u044f=\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435;<\/code><\/p>\n<pre><code class=\"python\">raw_cookies = ''.join(['{}={}; '.format(i['name'], i['value']) for i in cookies])<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0437\u0430\u0434\u0430\u043d\u0438\u0439 Windows. \u041f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0430 <code>.py<\/code> \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 <code>.bat<\/code> \u043e\u0434\u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>python \"script.py\"<\/code>. \u0414\u0430, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u043a\u043d\u043e \u043a\u043e\u043d\u0441\u043e\u043b\u0438. \u0415\u0441\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441\u043a\u0440\u044b\u0442\u043d\u043e.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043d\u0430 \u0442\u0440\u0435\u0442\u0438\u0439 \u0434\u0435\u043d\u044c \u0438 240 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u0432 \u0440\u0430\u0439\u043e\u043d\u0435 17 \u0447\u0430\u0441\u043e\u0432 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438. \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/554406\/\"> https:\/\/habr.com\/ru\/post\/554406\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-322123","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322123"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322123\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}