Submission of auto-requests on the FTS website in USR on python
The FTS website at egrul.nalog.ru/index.html has a wonderful service for checking counterparties or their own companies.
The essence of the verification is reduced to submitting a request to the Unified State Register of Legal Entities (single register of facts of legal entities' details) and receiving an extract from the registry right there online.
Working with the service does not cause any difficulties: entered into the OGRN field, clicked the “Search” button and clicked the “Download” button below. All statement received. ')
How can automation help here? Very simple.
If your holding consists of n-number of legal entities, then even such work as copy-pasting of the OGRN in the search bar of the service can be annoying.
Let's get rid of the routine and automate the process of submitting and downloading extracts from the Unified State Register of Legal Entities! In our case, the program will “pick up” one OGRN from the previously prepared excel table, enter the value in the service line, press the necessary buttons.
Ideally, the program will work like this:
Let's get started
To begin with, we will prepare an excel spreadsheet, where we will add OGRNs, according to which we will work, in a column:
The number of OGRN does not matter (you can even download the entire Unified Register), the main thing is that they should all be in column A.
Name the statement file as EGRY.xlsx and save it in the working directory python.
Now create the file itself with the program - egrul.py.
The first lines of the program, as usual, begin with the import of the necessary modules, then we select the browser (in my case, Chrome) and “go in” to the website:
Next, we run a cycle on all OGRN in the excel table:
Here you need to pay attention to the values ​​of x at the beginning of the cycle:
2- this is the starting cell with OGRN (starting), which corresponds to A2 in the excel table. The final cell will be A9, although the number in the cycle is 10.
It must be borne in mind that all OGRNs are processed and the last value is not lost. Between the filings of requests to the Unified State Register of Legal Entities, the program lasts a pause of 30 seconds. This may seem unacceptably long and this period will want to be shortened. This can be done by changing the value in the string time.sleep (30) to, for example, time.sleep (10). However, in this case, you can get under the sanctions of the FTS service and get the captcha. This captcha can be circumvented, but this is a topic for a separate post. And in this program, it is better to leave a delay between 30 seconds for submitting requests and go quietly to drink tea while the program is working for you.