mirror of https://github.com/vane/ceidg
feat: directory for each year of data
This commit is contained in:
parent
4fb2ff8b9f
commit
267b95f0fa
|
@ -25,7 +25,7 @@ jobs:
|
|||
python ceidg.py
|
||||
- name: Commit files
|
||||
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 add data
|
||||
git commit -m "Update data" -a
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
*.iml
|
||||
.venv
|
||||
|
|
12
ceidg.py
12
ceidg.py
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
from bs4 import BeautifulSoup, Comment
|
||||
from datetime import datetime
|
||||
import requests
|
||||
|
@ -13,7 +14,14 @@ 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:
|
||||
|
||||
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}')
|
||||
|
|
Loading…
Reference in New Issue