defi-rendu-legifrance/fetchbs.py
2018-11-06 21:10:37 +01:00

22 lines
905 B
Python
Executable File

#!/usr/bin/env python3
#-*- coding: utf-8 -*-
# Imports
import requests
from bs4 import BeautifulSoup
def runfetch():
site = requests.get("https://www.legifrance.gouv.fr/eli/arrete/2018/10/12/PRMD1824595A/jo/texte").text
soup = BeautifulSoup(site, "html.parser")
trs = soup.findAll("tr")
tds = []
for tr in trs:
tds.append([])
for td in BeautifulSoup(tr.prettify(), "html.parser").findAll("td"):
tds[-1].append(td.text)
print(trs)
if __name__ == "__main__":
runfetch()
['\n\n 289\n ', '\n\n PAÏTA\n ', '\n\n TONTOUTA\n ', '\n\n 988 - Nouvelle-Calédonie\n ', "\n\n polygone délimité par les points :\n \n A : 166° 12' 46” E / 22° 00' 59” S\n \n B : 166° 12' 32” E / 22° 01' 26” S\n \n C : 166° 12' 51” E / 22° 01' 36” S\n \n D : 166° 13' 05” E / 22° 01' 11” S\n ", '\n\n Ministère des armées\n ', '\n']