This Python script fetches blacklist data from a specified API endpoint and writes it to a new CSV file. It is designed to facilitate automated data retrieval and file operations through APIs.
- Fetching data from APIs
- Support for HTTP Basic Authentication
- Authentication using API tokens
- Sending JSON body parameters for POST requests
- Backing up existing output files
The script can be run with the following parameters:
python3 script.py --url <url> --output_file <output_file> [--api_token <api_token>] [--header <header>] [--username <username>] [--password <password>] [--body <body>]
--url <url>
: URL of the API endpoint including query parameters.--output_file <output_file>
: Path to the output CSV file.--api_token <api_token>
: (Optional) Token for API authentication.--header <header>
: (Optional) Custom header for the request.--username <username>
: (Optional) Username for HTTP Basic Authentication.--password <password>
: (Optional) Password for HTTP Basic Authentication.--body <body>
: (Optional) JSON formatted body for POST requests.
To fetch data from an API:
python3 script.py --url "https://api.example.com/data" --output_file "output.csv"
If an API token is required:
python3 script.py --url "https://api.example.com/data" --output_file "output.csv" --api_token "your_api_token"
Using HTTP Basic Authentication:
python3 script.py --url "https://api.example.com/data" --output_file "output.csv" --username "user" --password "password"
Before using this script, you need to install the required libraries:
pip install requests
This project is licensed under the MIT License. For more information, see the LICENSE
file.