📜 ⬆️ ⬇️

Extracts from Rosreestr through FSIS USRN and python. Part 1 - Sample

Cheap statements, what could be better?


Roman Andreyevich Kartsev has a good monologue about yesterday's crayfish for 5 rubles. and today's for 3. We assume that the last post was about crayfish for 5 rubles. Since the extract from the USRN is 300 rubles each, although not everyone can afford it, if it comes to mass requests.

This time, consider how to get the same result by spending 400 rubles. for 100 extracts from the USRN. Our program will perform simple manipulations, go to the site, fill in for us all the necessary fields when submitting a request to Rosreestr. Like last time, we will not use the Rosreestr api.

It will look something like this:


The Rosreestra portal assumes that when working with the FSIS, you will receive a key on the portal - a character-numeric string. This key is entered one-time when working with the Federal State Information Service to enter the workspace and is contained in the My Keys section:
')


We assume that you received the key yourself. The procedure for obtaining it is not complicated.
Now we’ll write a program that automates the submission of requests.

Let's start with a simple program that will submit one request to the system.

Requests in USRN - version 2.0


Import modules:

import webbrowser,time from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import NoSuchElementException import os 

We go to the website of the FSIS USRN:

 browser = webdriver.Firefox() browser.implicitly_wait(40) browser.get ('https://rosreestr.ru/wps/portal/p/cc_present/ir_egrn') 

We will be greeted by a friendly window for entering the Rosreestr key, which was discussed above:



We determine the CSS-selector of the window where the key should be entered, enter your key and go to the Federal State Registration Service Register, by clicking the "Enter" button:

 act = browser.find_element_by_css_selector('.v-panel-content > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)') for i in '---------': act.send_keys(i) time.sleep(2) act = browser.find_element_by_css_selector('.v-panel-content > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > input:nth-child(1)') for i in '----': act.send_keys(i) time.sleep(2) act = browser.find_element_by_css_selector('.v-panel-content > div:nth-child(1) > div:nth-child(1) > div:nth-child(5) > div:nth-child(1) > input:nth-child(1)') for i in '----': act.send_keys(i) time.sleep(2) act = browser.find_element_by_css_selector('.v-panel-content > div:nth-child(1) > div:nth-child(1) > div:nth-child(7) > div:nth-child(1) > input:nth-child(1)') for i in '----': act.send_keys(i) time.sleep(2) act = browser.find_element_by_css_selector('.v-panel-content > div:nth-child(1) > div:nth-child(1) > div:nth-child(9) > div:nth-child(1) > input:nth-child(1)') for i in '--------': act.send_keys(i) time.sleep(2) act = browser.find_element_by_css_selector('.v-button-normalButton > span:nth-child(1) > span:nth-child(1)') act.click() time.sleep(2) 

Here you need to enter parts of your key into the fields with “-” symbols, since the program will enter it on the site in parts, jumping over the fields.

If everything works successfully, then we will get into the system window:



Since we will search for real estate, the program should click "Search for real estate", respectively:

 act = browser.find_element_by_css_selector('.v-gridlayout-margin > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > span:nth-child(1) > span:nth-child(2)') act.click() time.sleep(1) 

Now we will enter the cadastral number in the appropriate fields and indicate the area to search. Without entering data about the region, you cannot proceed to the next step:

 act = browser.find_element_by_css_selector('.v-verticallayout-searchFormOuter > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > input:nth-child(1)') act.click() for i in '66:36:2801001:223': act.send_keys(i) act = browser.find_element_by_css_selector('.v-filterselect-error > input:nth-child(1)') act.click() for i in ' ': act.send_keys(i) time.sleep(5) act.send_keys(Keys.ENTER) act = browser.find_element_by_css_selector('.v-horizontallayout-borderTop > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > span:nth-child(1) > span:nth-child(1)') act.click() 

Our next window:



Here you need to click on the object formed at the bottom of the page, do this:

 act = browser.find_element_by_css_selector('.v-table-table') act.click() 

And we get to the final step, where we are again met by the captcha. We also need to click on the send request button:



Enter the captcha using the interpreter manually. So far, we use this method of “circumventing” captcha:

 act = browser.find_element_by_css_selector('.v-textfield') act.click() i=input("     ENTER: ") for a in i: act.send_keys(a) time.sleep(1) act.send_keys(Keys.ENTER) 

* That is, the program will wait until the user manually enters the captcha in the window with the program and presses “enter”.

And, further, the program itself sends a request to the Federal State Property Inspection Register:

 act = browser.find_element_by_css_selector('.v-horizontallayout-blockNotTall > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > span:nth-child(1) > span:nth-child(1)') act.click() time.sleep(3) 

And clicks on “Continue to work”:



We have successfully submitted a request for one object.

You can verify that the request has indeed been successfully sent to the FSIS in the "My Applications" section, which we are informed about.

Now we need to start the program cycle for all objects in the excel table and ... somehow defeat the captcha. However, this is a completely different story. Although the hint remained in the program code, uploaded to the exchanger.

Download the program - here .

Source: https://habr.com/ru/post/461045/


All Articles