Commit 8fe8dbd5 authored by Daniel STAN's avatar Daniel STAN

first draft d'import depuis csp

parent 4f2b8ce6
#!/bin/env python3
# -*- coding: utf-8 -*-
import bs4
import decimal
def parse_decimal(txt):
"""Parse un décimal vu comme un montant en €"""
txt = txt.replace(' ','').replace(',', '.').replace('€', '')
return decimal.Decimal(txt)
value = parse_decimal(dep.findAll(attrs={'class':'col-xs-3'})[0].text)
doc = bs4.BeautifulSoup(open('1.example', 'r').read())
# Replace expenses with payback, for second form
r = doc.find(attrs={'id': 'expenses_accordion'})
depenses = r.findAll(attrs={'class': 'panel panel-default'})
# On va parser une dépense donnée
dep = depenses[0]
title = dep.find(attrs={'class': 'col-xs-6'}).text
value = parse_decimal(dep.findAll(attrs={'class':'col-xs-3'})[0].text)
unique_id = int(dep.findAll('a')[-1].attrs['href'].split('=')[-1])
participants = dep.find(attrs={'class': 'panel-body'}).text.split('\n')[1]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment