{"id":312673,"date":"2020-11-06T15:00:54","date_gmt":"2020-11-06T15:00:54","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=312673"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=312673","title":{"rendered":"XPATH + XML = \u0431\u044b\u0441\u0442\u0440\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ty\/qn\/nb\/tyqnnbgf3db_zzcjpuzudwjod-y.jpeg\"><\/p>\n<p>  \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u044f\u0437\u044b\u043a XPath \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0442\u0430\u043a\u0438\u043c\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043a\u0430\u043a \u0443\u0437\u043b\u044b. \u0423\u0437\u043b\u044b \u0431\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0438\u0434\u043e\u0432: element (\u0443\u0437\u0435\u043b-\u044d\u043b\u0435\u043c\u0435\u043d\u0442), attribute (\u0443\u0437\u0435\u043b-\u0430\u0442\u0440\u0438\u0431\u0443\u0442), text (\u0443\u0437\u0435\u043b-\u0442\u0435\u043a\u0441\u0442), namespace (\u0443\u0437\u0435\u043b-\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d), processing-instruction (\u0443\u0437\u0435\u043b-\u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f), comment (\u0443\u0437\u0435\u043b-\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439), document (\u0443\u0437\u0435\u043b-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442).<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432 XPATH \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u0437\u043b\u043e\u0432, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0443\u0437\u043b\u044b \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0443\u0437\u043b\u043e\u0432 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f 6 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/td\/xx\/ia\/tdxxiaunm7lpwxzkagohvcmfrco.jpeg\"><\/p>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0443\u0437\u043b\u043e\u0432 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c wildcard \u043c\u0430\u0441\u043a\u0438, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043a\u0430\u043a\u043e\u0439 \u0432\u0438\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0443\u0437\u0435\u043b.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fi\/ea\/n9\/fiean9by4ebjkynjqyaislicfjs.jpeg\"><\/p>\n<p>  \u0412 \u044f\u0437\u044b\u043a\u0435 XPATH \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043e\u0441\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/zj\/os\/nx\/zjosnxn4xdhkknmmaei3j_urlkk.jpeg\"><\/p>\n<p>  \u041f\u0440\u0430\u0432\u0438\u043b\u043e \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u043c (\/\/input[@placeholder=\u201d\u041b\u043e\u0433\u0438\u043d\u201d \u2013 \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0443\u0437\u043b\u0430], \u0442\u0430\u043a \u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c (*@class=\u201dokved-table__code\u201d \u2013 \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430).<\/p>\n<p>  \u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0443\u0437\u043b\u0430 \u0438 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442:<\/p>\n<ul>\n<li>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u0441\u0438, \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443<\/li>\n<li>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0443\u0437\u043b\u0430 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u0438\u043b\u0438 \u043f\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044e<\/li>\n<li>\u041d\u043e\u043b\u044c \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u0432<\/li>\n<\/ul>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0448\u0430\u0433\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438\u043c\u0435\u0435\u0442 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"python\">axisname::nodetest[predicate]<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 \u043f\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0438\u043b\u0438 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u0430\u043a\u043e\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u043a\u0430\u043a \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u044b. \u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430 \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445. \u041f\u0440\u0438\u043c\u0435\u0440\u044b:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/5l\/dj\/hi\/5ldjhiypain_b86afsr6aoaascs.jpeg\"><\/p>\n<p>  \u041f\u043e\u043c\u0438\u043c\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u044f\u0437\u044b\u043a\u0430 XPATH, \u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u044f\u0434 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 (+, -, *, div, mod, =, !=, and, or \u0438 \u0442.\u0434.), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 200 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u041d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043b\u044e\u0434\u0435\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u043c notariat.ru.<\/p>\n<p>  \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"python\">from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.chrome.options import Options from bs4 import BeautifulSoup from multiprocessing import Pool from retry import retry import itertools, time, pprint, os, re, traceback, sys, datetime import pandas as pd, numpy as np, multiprocessing as mp<\/code><\/pre>\n<p>  \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043b\u044e\u0434\u044f\u043c:<\/p>\n<pre><code class=\"python\">df_people = pd.read_excel('people.xlsx')<\/code><\/pre>\n<p>  \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u043b\u044e\u0434\u044f\u0445.<\/p>\n<pre><code class=\"python\">def find_persons(driver, name, birth_date):     base_url = 'https:\/\/notariat.ru\/ru-ru\/help\/probate-cases\/'     # \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u043e\u0438\u0441\u043a\u0430 \u043b\u044e\u0434\u0435\u0439     driver.get(base_url)     # \u041f\u043e\u0438\u0441\u043a \u043f\u043e\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u0438\u043c\u0435\u043d\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f     driver.find_element_by_xpath('\/\/input[@name=&quot;name&quot;]').send_keys(name)     # \u041f\u043e\u0438\u0441\u043a \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0434\u043d\u044f \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f     driver.find_element_by_xpath('\/\/select[@data-placeholder=&quot;\u0414\u0435\u043d\u044c&quot;]\/following::div\/a').click()    # \u0412\u044b\u0431\u043e\u0440 \u0434\u043d\u044f \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u0437 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430      driver.find_element_by_xpath('\/\/select[@data-placeholder=&quot;\u0414\u0435\u043d\u044c&quot;]\/following::div\/\/li[@data-option-array-index={}]'.format(birth_date.day)).click()     # \u041f\u043e\u0438\u0441\u043a \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0434\u043d\u044f \u043c\u0435\u0441\u044f\u0446\u0430     driver.find_element_by_xpath('\/\/select[@data-placeholder=&quot;\u041c\u0435\u0441\u044f\u0446&quot;]\/following::div\/a').click()    # \u0412\u044b\u0431\u043e\u0440 \u043c\u0435\u0441\u044f\u0446\u0430 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u0437 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430      driver.find_element_by_xpath('\/\/select[@data-placeholder=&quot;\u041c\u0435\u0441\u044f\u0446&quot;]\/following::div\/\/li[@data-option-array-index={}]'.format(birth_date.month)).click()     # \u0412\u0432\u043e\u0434 \u0433\u043e\u0434\u0430 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438     driver.find_element_by_xpath('\/\/input[@placeholder=&quot;\u0413\u043e\u0434&quot;]').send_keys(str(birth_date.year))     # \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430     driver.find_element_by_xpath('\/\/*[contains(., &quot;\u0418\u0441\u043a\u0430\u0442\u044c \u0434\u0435\u043b\u043e&quot;)]').click()     # \u041e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0434\u043e 20 \u0441\u0435\u043a\u0443\u043d\u0434 \u0434\u043e \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043b\u044e\u0434\u0435\u0439, \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u00abprobate-cases__result-list\u00bb     WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CLASS_NAME, &quot;probate-cases__result-list&quot;)))     time.sleep(2)          # \u0418\u0449\u0435\u043c \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438     max_pages = 1     pages_counters = driver.find_elements_by_xpath('\/\/a[@class=&quot;pagination__item-content&quot;]')     if pages_counters:         max_pages = int(pages_counters[-1].text)          data = []     def parse_page_data():         # \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e \u043b\u044e\u0434\u044f\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430         lines = driver.find_elements_by_xpath('\/\/ol[@class=&quot;probate-cases__result-list&quot;]\/li')         for line in lines:             name = ' '.join(map(lambda el: el[0].upper() + el[1:].lower(), line.find_element_by_xpath('.\/\/h4').text.split()))             death_date = datetime.datetime.strptime(line.find_element_by_xpath('.\/\/p').text.split(':')[-1].strip(), '%d.%m.%Y')             data.append((name, birth_date, death_date))     # \u0415\u0441\u043b\u0438 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438     if max_pages == 1:         parse_page_data() # \u0442\u043e \u043f\u0430\u0440\u0441\u0438\u043c \u0442\u043e \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u043c     else:          for page_num in range(1, max_pages + 1):             # \u0418\u043d\u0430\u0447\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043a\u043b\u0438\u043a\u0430\u044f \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b             driver.find_element_by_xpath('\/\/li[.\/a[@class=&quot;pagination__item-content&quot; and text()=&quot;{}&quot;]]'.format(page_num)).click()             time.sleep(0.2)             # \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b             parse_page_data()     return data<\/code><\/pre>\n<p>  \u041e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0438\u0441\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u043e\u0434\u0443\u043b\u044c multiprocessing, \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0441\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"python\">def parse_persons(persons_data_chunk, pool_num):     # \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440 Chrome \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 headless \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c (\u041f\u0440\u0438 \u043c\u0435\u043d\u044c\u0448\u0435\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u044b DOM \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 notariat.ru \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f)     chrome_options = Options()     chrome_options.add_argument(&quot;--headless&quot;)     chrome_options.add_argument(&quot;--window-size=1920,1080&quot;)     driver = webdriver.Chrome(options=chrome_options)     driver.set_page_load_timeout(20)     data = []      print(pool_num, '')     # \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u0438\u0441\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0443 \u0438\u0437 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b     for ind, (person_name, person_date) in enumerate(persons_data_chunk, start=1):         print('pool:', pool_num, ', person: ', ind, '\/', len(persons_data_chunk))         try:             data.extend(find_persons(driver, person_name, person_date))         except Exception as e:             print(pool_num, 'failed to load', person_name, person_date, &quot;error:&quot;, e)             traceback.print_exception(*sys.exc_info())      print(pool_num, 'done')     return data  def parse(people_data, parts=5):     p = mp.Pool(parts)     # \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0443 \u0441\u043f\u0438\u0441\u043a\u0430 \u043b\u044e\u0434\u0435\u0439 \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0434\u043b\u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445     people_in_chanks = np.array_split(people_data, parts if parts &lt; len(people_data) else 1) or []     all_data = p.starmap(parse_persons, zip(people_in_chanks, range(parts)))     out = []     for el in all_data:         out.extend(el)     return out parsed_data = parse(people_data)<\/code><\/pre>\n<p>  \u0418 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<pre><code class=\"python\">df = pd.DataFrame({     '\u0424\u0418\u041e': list(map(lambda el: el[0], parsed_data)),     &quot;\u0414\u0430\u0442\u0430 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f&quot;: list(map(lambda el: el[1], parsed_data)),     '\u0414\u0430\u0442\u0430 \u0441\u043c\u0435\u0440\u0442\u0438': list(map(lambda el: el[2], parsed_data)) }) df.to_excel('results.xlsx', index=False)<\/code><\/pre>\n<p>  \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 \u043b\u0438\u0447\u043d\u044b\u0445 \u0434\u0435\u043b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0424\u0418\u041e, \u0434\u0430\u0442\u0430 \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a. \u041f\u043e\u0441\u043b\u0435 \u0432\u0432\u043e\u0434\u0430 \u0424\u0418\u041e \u0438 \u0434\u0430\u0442\u044b \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u0438\u0441\u043a\u0430\u0442\u044c \u0434\u0435\u043b\u043e, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lm\/wd\/2k\/lmwd2kk3ju1a4kczb4dug2btvow.png\"><\/p>\n<p>  \u041d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u0432\u0438\u0434\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a, \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7b\/zv\/5l\/7bzv5l3z-huq9r-ml0rlv1jsbqk.png\"><\/p>\n<p>  \u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c XPATH \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0441 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446. \u041d\u043e \u043a\u0430\u043a \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e, XPATH \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043b\u044e\u0431\u044b\u0445 xml \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u044f\u0432\u043b\u044f\u044f\u0441\u044c \u043e\u0442\u0440\u0430\u0441\u043b\u0435\u0432\u044b\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c xml \u0438 xhtml, xslt \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439.<\/p>\n<p>  \u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0432\u043b\u0438\u044f\u0435\u0442 \u0438 \u043d\u0430 \u0435\u0433\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0435, \u0438\u0437\u0443\u0447\u0438\u0442\u044c XPATH \u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0430\u0448 \u043a\u043e\u0434 \u043f\u0440\u043e\u0449\u0435, \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435. \u0412\u044b \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u0448\u0438\u0431\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438.<\/p><\/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\/526774\/\"> https:\/\/habr.com\/ru\/post\/526774\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ty\/qn\/nb\/tyqnnbgf3db_zzcjpuzudwjod-y.jpeg\"><\/p>\n<p>  \u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u044f\u0437\u044b\u043a XPath \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0442\u0430\u043a\u0438\u043c\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043a\u0430\u043a \u0443\u0437\u043b\u044b. \u0423\u0437\u043b\u044b \u0431\u044b\u0432\u0430\u044e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0432\u0438\u0434\u043e\u0432: element (\u0443\u0437\u0435\u043b-\u044d\u043b\u0435\u043c\u0435\u043d\u0442), attribute (\u0443\u0437\u0435\u043b-\u0430\u0442\u0440\u0438\u0431\u0443\u0442), text (\u0443\u0437\u0435\u043b-\u0442\u0435\u043a\u0441\u0442), namespace (\u0443\u0437\u0435\u043b-\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0451\u043d), processing-instruction (\u0443\u0437\u0435\u043b-\u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f), comment (\u0443\u0437\u0435\u043b-\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439), document (\u0443\u0437\u0435\u043b-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442).<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432 XPATH \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u0437\u043b\u043e\u0432, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0443\u0437\u043b\u044b \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438.  <\/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-312673","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/312673","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=312673"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/312673\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}