This repository contains scripts to fetch and download Form C1 images from the Indonesian General Election Commission (KPU) API. The provided scripts are available in both JavaScript (Node.js) and Python.
The Indonesian General Election Commission (KPU) provides an API that allows access to election-related data, including Form C1 images. This repository contains scripts to fetch data from the KPU API and download Form C1 images sequentially.
Ensure that you have the following software installed on your system:
- Clone the repository to your local machine:
git clone https://github.com/RehanDias/sirekapC1-download.git
- Navigate to the repository directory:
cd sirekapC1-download
- Install dependencies for the JavaScript script if you want to run the JavaScript file:
npm install axios
No additional dependencies are required for the Python script.
The JavaScript script (sirekap-v.js
) fetches data from the KPU API and downloads Form C1 images sequentially.
- Run the script using the following command:
node sirekap-v.js
- The script will create directories for each administrative division (province, regency/municipality, district, village), fetch the necessary data from the KPU API, and download the Form C1 images into their respective folders.
The Python script (sirekap-v.py
) also fetches data from the KPU API and downloads Form C1 images sequentially.
- Run the script using the following command:
python sirekap-v.py
- The script performs similar operations as the JavaScript script, creating directories for administrative divisions, fetching data from the KPU API, and downloading the Form C1 images.
While both scripts achieve the same goal of fetching and downloading Form C1 images from the KPU API, there are some differences in their implementation:
- Language: The JavaScript script is written in Node.js, while the Python script is written in Python.
- Dependencies: The JavaScript script requires the
axios
library for making HTTP requests, while the Python script uses built-in libraries such asurllib.request
for the same purpose. - Error Handling: Error handling mechanisms may vary between the two scripts due to differences in language constructs and libraries used.
The JavaScript script (sirekap-v.js
) consists of the following main components:
- ImageDownloader Class: Manages the downloading of images from URLs with retry mechanisms.
- DataFetcher Class: Fetches data from the KPU API and downloads images sequentially for administrative divisions.
- Main Execution: The
fetchData()
function initiates the data fetching and image downloading process.
The Python script (sirekap-v.py
) comprises the following main components:
- ImageDownloader Class: Manages image downloading with retry mechanisms.
- DataFetcher Class: Fetches data from the KPU API and downloads images sequentially for administrative divisions.
- Main Execution: The
fetch_data()
function starts the data fetching and image downloading process.
Contributions are welcome! Feel free to submit pull requests or open issues for any improvements or bug fixes.
This project is licensed under the MIT License.