Improved readabilty (i guess)
This commit is contained in:
parent
4611a66276
commit
11ee2cda27
7
fetch.py
Normal file → Executable file
7
fetch.py
Normal file → Executable file
@ -5,7 +5,10 @@ Created on Mon Nov 5 20:55:36 2018
|
|||||||
|
|
||||||
@author: suwako
|
@author: suwako
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
def runfetch(url):
|
def runfetch(url):
|
||||||
session=requests.Session()
|
session=requests.Session()
|
||||||
req1=session.get(url)
|
req1=session.get(url)
|
||||||
@ -15,7 +18,11 @@ def runfetch(url):
|
|||||||
for row in text:
|
for row in text:
|
||||||
cols=[text.split('\n')[2][5::] if len(text.split('\n'))==3 else "" for text in row.split("</td")[::]]
|
cols=[text.split('\n')[2][5::] if len(text.split('\n'))==3 else "" for text in row.split("</td")[::]]
|
||||||
diclist.append({"id":cols[0],"commune":cols[1],"site":cols[2],"departement":cols[3],"zone":cols[4],"ministere":cols[5],"aerozone":cols[6]})
|
diclist.append({"id":cols[0],"commune":cols[1],"site":cols[2],"departement":cols[3],"zone":cols[4],"ministere":cols[5],"aerozone":cols[6]})
|
||||||
|
#dicformat:{id,commune,site,departement,zone,ministere,aerozone}
|
||||||
return diclist
|
return diclist
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
diclist=runfetch('https://www.legifrance.gouv.fr/eli/arrete/2018/10/12/PRMD1824595A/jo/texte')
|
diclist=runfetch('https://www.legifrance.gouv.fr/eli/arrete/2018/10/12/PRMD1824595A/jo/texte')
|
||||||
url='https://www.legifrance.gouv.fr/eli/arrete/2018/10/12/PRMD1824595A/jo/texte'
|
url='https://www.legifrance.gouv.fr/eli/arrete/2018/10/12/PRMD1824595A/jo/texte'
|
||||||
|
print(diclist)
|
Loading…
Reference in New Issue
Block a user