Get extracts from the register on the FTS website using python

The website of the Federal Tax Service at egrul.nalog.ru/index.html has a wonderful service for checking contractors or their own companies.

The essence of the check is to submit a request to the Unified State Register of Legal Entities (a unified register of facts of the details of legal entities) and to receive an extract from the register right there, online.

Working with the service does not cause any difficulties: I added it to the PSRN, clicked the “Find” button, and clicked the “Download” button below. Everything, the extract is received.

How can automation help here? Very simple.

If your holding consists of an n-number of legal entities, then even a job such as copying OGRN into a service search string can get bored.

We will get rid of the routine and automate the process of filing and downloading extracts from the register!

In our case, the program will “pick up” one OGRN from a pre-prepared excel table, enter the value in the service line, press the necessary buttons.

Ideally, the program will look like this:


Let's get started.

First, prepare the excel table, where we will add the OGRN, according to which we will work, in the column: The



number of OGRN does not matter (you can even download the whole USRLE), the main thing is that they all be in column A.

We will name the extract file EGRUL.xlsx and save it in the working python directories.

Now create the file with the program itself - 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” to the site:



Next, we start the loop through all the PSRNs in the excel table:



Here you need to pay attention to the x values ​​at the beginning of the cycle :



2- this is the initial cell with OGRN (start), which corresponds to A2 in the excel table. The final cell will be A9, although the number 10 is indicated in the loop.

This must be borne in mind that all OGRN were processed and the last value was not lost.
The program withstands a pause of 30 seconds between filing a request with the USRLE. This may seem unacceptably long and this period will want to be shortened. This can be done by changing the value in the line time.sleep (30) to, for example, time.sleep (10). However, in this case, you can fall under the sanctions of the Federal Tax Service and get captcha. You can get around this captcha, but this is a topic for a separate post. And in this program, it is better to leave a delay between submissions of requests at 30 seconds and go quietly drink tea while the program works for you.

The link to the program is here .

Link to excel test chart here .

Also popular now: