Skip to content

Instantly share code, notes, and snippets.

@fmassot
Last active August 29, 2015 14:17
Show Gist options
  • Save fmassot/e48269bef73e038228ed to your computer and use it in GitHub Desktop.
Save fmassot/e48269bef73e038228ed to your computer and use it in GitHub Desktop.
AN QE xml api
import xmltodict
def parse_question(response):
data = xmltodict.parse(response.content)
qe = data['QUESTION']
print qe
extracted_data = {
'source': response.url.replace('/vue/xml', ''),
'legislature': qe['LEGISLATURE'],
'type': qe['@TYPE'],
'numero': qe['DEPOT'][0]['@NUMERO'],
'date_question': qe['DEPOT'][0]['DATE_JO'],
'date_retrait': qe['CLOTURE']['DATE_JO'],
'date_reponse': qe['REPONSE']['DATE_JO_REPONSE'],
'date_signalement': '',
'date_cht_attr': '',
'page_question': qe['DEPOT'][0]['PAGE_JO'],
'page_reponse': qe['REPONSE']['PAGE_JO_REPONSE'],
'ministere_attribue': '',
'ministere_interroge': qe['MINI']['DEVELOPPE'],
'tete_analyse': qe['INDEXATION_AN']['TETE_ANALYSE'],
'analyse': qe['INDEXATION_AN']['ANALYSE']['ANA'],
'rubrique': qe['INDEXATION_AN']['@RUBRIQUE'],
'question': qe['DEPOT'][1]['TEXTE_DEPOT'],
'reponse': qe['REPONSE']['TEXTE_REPONSE'],
'motif_retrait': '',
'auteur': qe['AUTEUR']['PRENOM'] + ' ' + qe['AUTEUR']['NOM'],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment