2020-03-21 17:33:03 +00:00
|
|
|
#!/usr/bin/python3
|
2021-01-28 11:52:33 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2020-03-21 17:33:03 +00:00
|
|
|
import requests
|
2021-01-28 11:52:33 +00:00
|
|
|
from bs4 import BeautifulSoup
|
2020-03-21 17:33:03 +00:00
|
|
|
|
|
|
|
urlAnd = 'https://www.govern.ad/covid/taula.php'
|
|
|
|
headers = {'User-Agent':'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0'}
|
|
|
|
|
|
|
|
resp = requests.get(urlAnd, headers=headers)
|
2021-01-28 11:52:33 +00:00
|
|
|
webAnd = BeautifulSoup(resp.text, "lxml")
|
|
|
|
webAnd = webAnd.get_text()
|
|
|
|
webAnd = webAnd.split('\n')
|
|
|
|
webAnd = [line for line in webAnd if line.strip() != ""]
|
2020-03-21 17:33:03 +00:00
|
|
|
|
|
|
|
outfile = open("and.txt", "w")
|
|
|
|
|
2021-01-28 11:52:33 +00:00
|
|
|
i=0
|
|
|
|
tmp=''
|
|
|
|
for txt in webAnd:
|
|
|
|
if i == 0:
|
|
|
|
outfile.write(txt+'\n')
|
|
|
|
outfile.write('\n')
|
|
|
|
elif i==11:
|
|
|
|
outfile.write('\n-------\n')
|
|
|
|
outfile.write(txt+'\n')
|
|
|
|
outfile.write('\n')
|
|
|
|
elif i%2==1:
|
|
|
|
tmp=txt+': '
|
|
|
|
elif i%2==0:
|
|
|
|
tmp=tmp+txt+'\n'
|
|
|
|
outfile.write(tmp)
|
|
|
|
tmp=''
|
|
|
|
|
|
|
|
i+=1
|
2020-03-21 17:33:03 +00:00
|
|
|
|
|
|
|
outfile.close()
|