1
0
mirror of https://github.com/vane/ceidg synced 2024-11-16 07:05:51 +01:00
ceidg/ceidg.py

20 lines
797 B
Python
Raw Normal View History

2021-01-13 09:41:20 +01:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup, Comment
from datetime import datetime
import requests
2021-02-04 15:52:29 +01:00
import urllib3
2021-02-04 20:48:29 +01:00
2021-02-04 20:50:02 +01:00
url = 'http://prod.ceidg.gov.pl/ceidg.cms.engine/Template/Includes/StatisticPage.aspx?Id=3814CF7F-246D-4CC3-8B89-88AA1395DF1D'
2021-01-13 09:41:20 +01:00
resp = requests.get(url)
soup = BeautifulSoup(resp.content, 'html.parser')
tdlist = soup.find_all('td')
registered = tdlist[1].text.strip()
renewed = tdlist[3].text.strip()
suspended = tdlist[5].text.strip()
closed = tdlist[7].text.strip()
all = BeautifulSoup(str(soup.find_all(string=lambda text: isinstance(text, Comment))[0]), 'html.parser').find_all('td')[1].text.strip()
dt = datetime.now().strftime('%Y-%m-%d')
with open(f'data/{dt}.txt', 'w+') as f:
f.write(f'{registered},{renewed},{suspended},{closed},{all}')