Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Python client for website

Project description

ANpy: Scrape painlessly Assemblée Nationale website

PyPI version Build Status Coverage Status

ANpy is a python library for easily scraping data from website

Forget the ugly html, just get data:

>>> from anpy.dossier import Dossier
>>> url = ''
>>> dossier = Dossier.download_and_build(url)
>>> dossier.title
'Economie : pour une République numérique'
>>> dossier.legislature
>>> r.procedure
>>> r.senat_url
>>> r.steps
[{'type': 'AN_PREMIERE_LECTURE', 'acts': [...]}]

Supported Features

ANpy currently provides the following features:

  • Amendement parsing
  • Amendement search
  • Question parsing
  • Question search
  • Dossier parsing (two differents formats)
  • Scrutin parsing

ANpy supports Python 3.5.

Install :

pip install anpy


Documentation is available at


A script anpy-cli is installed with the package, it provides the following commands :

Show an amendement given its url

anpy-cli show_amendement

Show amendements summaries after a given date

anpy-cli show_amendements_summary --start-date 2014-06-01

Print amendements order for a given id_dossier and id_examen

anpy-cli show_amendements_order 33299 --id-examen 4073

Show a question

anpy-cli show_question

Show a law project (dossier législatif)

Format is like senapy and the Open Data of

There's more work done on this parser to make it work across many cases

anpy-cli parse
        "assemblee_id": "14-sante",
        "assemblee_legislature": 14,
        "assemblee_slug": "sante",
        "beginning": "2014-10-15",
        "long_title": "Questions sociales et santé : modernisation de notre système de santé",
        "steps": [
                "date": "2014-10-15",
                "institution": "assemblee",
                "source_url": "",
                "stage": "1ère lecture",
                "step": "depot"
                "date": "2015-03-20",
                "institution": "assemblee",
                "source_url": "",
                "stage": "1ère lecture",
                "step": "commission"
                "date": "2015-04-14",
                "institution": "assemblee",
                "source_url": "",
                "stage": "1ère lecture",
                "step": "hemicycle"


  • Merging the law project across legislatures
  • Parse from Open Data when available or fallback to scraping HTML
  • Returns an array of law projects since a page can contains many law projects (ex: organic + non-organic)

You can also parse many of them by giving a list of urls:

anpy-cli doslegs_urls | anpy-cli parse_many an_doslegs/

Show a law project (with a format is similar to the AN Open Data)

This parser is still a work-in-progress

anpy-cli show_dossier
    "legislature": "14",
    "procedure": "PJL",
    "senat_url": "",
    "steps": [
            "acts": [
                    "date": "2014-10-15T00:00:00",
                    "type": "DEPOT_INITIATIVE",
                    "url": ""
                    "type": "ETUDE_IMPACT",
                    "url": ""
                    "date": "2015-03-16T00:00:00",
                    "type": "PROCEDURE_ACCELEREE"
                    "date": "2015-03-20T00:00:00",
                    "type": "DEPOT_RAPPORT",
                    "url": ""
                    "date": "2015-03-24T00:00:00",
                    "type": "TEXTE_COMMISSION",
                    "url": ""
                    "date": "2015-02-11T00:00:00",
                    "type": "DEPOT_RAPPORT",
                    "url": ""

Find all the dossier urls

anpy-cli doslegs_urls

Show a scrutin

anpy-cli show_scrutin

Running the tests

pip install -U -r test_requirements.txt
pip install -e .
pycodestyle --exclude=tests,docs .
flake8 --exclude=tests,docs .
py.test --cov=anpy

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for anpy, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size anpy-0.2.1-py2.py3-none-any.whl (27.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size anpy-0.2.1.tar.gz (25.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page