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

feat: directory for each year of data

This commit is contained in:
Michal Szczepanski 2023-02-01 15:32:31 +01:00
parent 4fb2ff8b9f
commit 267b95f0fa
35 changed files with 12 additions and 3 deletions

@ -25,7 +25,7 @@ jobs:
python ceidg.py python ceidg.py
- name: Commit files - name: Commit files
run: | run: |
git config --local user.email "github.action@vane.pl" git config --local user.email "michal@vane.pl"
git config --local user.name "GitHub Action" git config --local user.name "GitHub Action"
git add data git add data
git commit -m "Update data" -a git commit -m "Update data" -a

1
.gitignore vendored

@ -1 +1,2 @@
*.iml *.iml
.venv

@ -1,5 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os
from bs4 import BeautifulSoup, Comment from bs4 import BeautifulSoup, Comment
from datetime import datetime from datetime import datetime
import requests import requests
@ -13,7 +14,14 @@ registered = tdlist[1].text.strip()
renewed = tdlist[3].text.strip() renewed = tdlist[3].text.strip()
suspended = tdlist[5].text.strip() suspended = tdlist[5].text.strip()
closed = tdlist[7].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() 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: dt = datetime.now()
fname = dt.strftime('%Y-%m-%d')
dt_folder_name = dt.strftime('%Y')
if not os.path.exists(f'data/{dt_folder_name}'):
os.makedirs(f'data/{dt_folder_name}')
with open(f'data/{dt_folder_name}/{fname}.txt', 'w+') as f:
f.write(f'{registered},{renewed},{suspended},{closed},{all}') f.write(f'{registered},{renewed},{suspended},{closed},{all}')