Skip to main content

Python client for assemblee-nationale.fr 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 http://assemblee-nationale.fr website

Forget the ugly html, just get data:

>>> from anpy.dossier import Dossier
>>> url = 'http://www.assemblee-nationale.fr/14/dossiers/republique_numerique.asp'
>>> dossier = Dossier.download_and_build(url)
>>> dossier.title
'Economie : pour une République numérique'
>>> dossier.legislature
14
>>> r.procedure
'PPL'
>>> r.senat_url
'http://www.senat.fr/dossier-legislatif/pjl15-325.html'
>>> 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

Documentation is available at http://anpy.readthedocs.io/en/latest

CLI

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

Show an amendement given its url

anpy-cli show_amendement http://www.assemblee-nationale.fr/14/amendements/1847/CION-DVP/CD266.asp

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 http://questions.assemblee-nationale.fr/q14/14-73499QE.htm

Show a law project (dossier législatif)

Format is like senapy and the Open Data of lafabriquedelaloi.fr

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

anpy-cli parse http://www.assemblee-nationale.fr/14/dossiers/sante.asp
[
    {
        "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": "http://www.assemblee-nationale.fr/14/projets/pl2302.asp",
                "stage": "1ère lecture",
                "step": "depot"
            },
            {
                "date": "2015-03-20",
                "institution": "assemblee",
                "source_url": "http://www.assemblee-nationale.fr/14/ta-commission/r2673-a0.asp",
                "stage": "1ère lecture",
                "step": "commission"
            },
            {
                "date": "2015-04-14",
                "institution": "assemblee",
                "source_url": "http://www.assemblee-nationale.fr/14/ta/ta0505.asp",
                "stage": "1ère lecture",
                "step": "hemicycle"
            },
...

Features:

  • 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 http://www.assemblee-nationale.fr/14/dossiers/sante.asp
{
    "legislature": "14",
    "procedure": "PJL",
    "senat_url": "http://www.senat.fr/dossier-legislatif/pjl14-406.html",
    "steps": [
        {
            "acts": [
                {
                    "date": "2014-10-15T00:00:00",
                    "type": "DEPOT_INITIATIVE",
                    "url": "http://www.assemblee-nationale.fr/14/projets/pl2302.asp"
                },
                {
                    "type": "ETUDE_IMPACT",
                    "url": "http://www.assemblee-nationale.fr/14/projets/pl2302-ei.asp"
                },
                {
                    "date": "2015-03-16T00:00:00",
                    "type": "PROCEDURE_ACCELEREE"
                },
                {
                    "date": "2015-03-20T00:00:00",
                    "type": "DEPOT_RAPPORT",
                    "url": "http://www.assemblee-nationale.fr/14/rapports/r2673.asp"
                },
                {
                    "date": "2015-03-24T00:00:00",
                    "type": "TEXTE_COMMISSION",
                    "url": "http://www.assemblee-nationale.fr/14/ta-commission/r2673-a0.asp"
                },
                {
                    "date": "2015-02-11T00:00:00",
                    "type": "DEPOT_RAPPORT",
                    "url": "http://www.assemblee-nationale.fr/14/rap-info/i2581.asp"
                },
                {
...

Find all the dossier urls

anpy-cli doslegs_urls

Show a scrutin

anpy-cli show_scrutin http://www2.assemblee-nationale.fr/scrutins/detail/(legislature)/14/(num)/1212

Project details


Download files

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

Source Distribution

anpy-0.1.24.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

anpy-0.1.24-py2.py3-none-any.whl (27.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file anpy-0.1.24.tar.gz.

File metadata

  • Download URL: anpy-0.1.24.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

File hashes

Hashes for anpy-0.1.24.tar.gz
Algorithm Hash digest
SHA256 fe48c751dfe1700f0ab6277e799bfcf7e5abe5125f224a3a826a8b71e32d6305
MD5 3ebe1806ab19e5fcf48a98450804b75c
BLAKE2b-256 891ededaee3336ab0e289bb092a72860f349a9703be5cb1349ac5f919da4955b

See more details on using hashes here.

File details

Details for the file anpy-0.1.24-py2.py3-none-any.whl.

File metadata

  • Download URL: anpy-0.1.24-py2.py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

File hashes

Hashes for anpy-0.1.24-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3e0b582444d659faf9e976bb224bf73f6d4dda5600a2e1a4065326e54230387c
MD5 02bcbd7b0a9db81482620a8ce618393f
BLAKE2b-256 755f50994a19eb691c58054e9e2e59b28baf3288308a6b19306002f039eef510

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page