File tree 1 file changed +4
-8
lines changed
1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change 4
4
import codecs
5
5
import pandas as pd
6
6
from bs4 import BeautifulSoup
7
- from datetime import datetime
8
7
9
- urlpath = "https://cbr.ru/vfs/mcirabis/BIKNew/"
10
- filename = datetime .now ().strftime ('%Y%m%d' ) + "ED01OSBR.zip"
11
8
outdir = "output/"
12
- outzip = outdir + filename
13
9
14
10
s = cloudscraper .create_scraper (disableCloudflareV1 = True , browser = "chrome" , delay = 10 )
15
11
16
12
for _ in range (3 ):
17
- r = s .get (urlpath + filename , allow_redirects = True )
13
+ r = s .get ("https://cbr.ru/s/newbik" , allow_redirects = True )
18
14
if r .status_code != 200 :
19
15
print (f"Error downloading zip: { r .status_code } " )
20
16
continue
21
- open (outzip , "wb" ).write (r .content )
17
+ open ("latest.zip" , "wb" ).write (r .content )
22
18
break
23
19
24
20
try :
25
- with zipfile .ZipFile (outzip , 'r' ) as zr :
21
+ with zipfile .ZipFile ("latest.zip" , "r" ) as zr :
26
22
zr .extractall (outdir )
27
- os .remove (outzip )
23
+ os .remove ("latest.zip" )
28
24
except Exception as e :
29
25
print (f"Error unpacking file: { e } " )
30
26
exit (1 )
You can’t perform that action at this time.
0 commit comments