A handy code wrapper to retrieve and parse data from the UK Parliamentary Petitions website.
This code accepts petition numbers, and automatically collects, parses, and saves data associated with that petition. The data collected and parsed from the petition can be saved in a time-separated manner to allow analysis of the petition's evolution over time.
This repo is written for Python 3. Python 2 compatibility is not guaranteed. See requirements.txt for a list of python packages this code depends on.
This repo is in the early stages of development
- Clone this repo and install the required packages.
- Find out the petition number of the petition for which you would like to collect data
- Find the path to the directory to which you would like data to be saved, relative to the top-level ParliamentaryPetitionParser directory. This defaults to data/.
- In the ParliamentaryPetitionParser directory, run
python -m src.petition --petition_number=NUM --output_dir=DIR
, where NUM is the petition number and DIR is the save directory. - Check your output directory location. You will have two files: constituency and country, which are prefixed by year_month_day_hour_minute_ and suffixed by the petition number.
You can also set ParliamentaryPetitionParser to collect data every X minutes. To do this, run
python -m src.petition --petition_number=NUM --output_dir=DIR --frequency=X