This Python script processes a list of parameters from a file and converts them into various formats (JSON, POST HTML, GET HTML, XML, Multipart Form Data) with options for limiting the number of parameters per output file and specifying output directories.
- Converts parameters into:
- JSON format (e.g.,
{"email": "emailnull'"}
). - POST HTML format (e.g.,
email=emailnull'&type=typenull'
). - GET HTML format (e.g.,
email=null&type=null
). - XML format (e.g.,
<parameters>\n <email>emailnull</email>\n</parameters>
). - Multipart Form Data format (e.g.,
--boundary\nContent-Disposition: form-data; name="email"\n\nemailnull\n--boundary--
).
- JSON format (e.g.,
- Allows limiting the number of parameters per output file.
- Creates the necessary output directories if they do not exist.
- Handles errors gracefully, such as missing files or invalid inputs.
- Python 3.x
-
Clone the repository:
git clone https://github.com/marz-hunter/convert-params.git cd convert-params
-
Ensure the required file (
params.txt
) is in the project directory.
Run the script using the following command:
python3 convert.py -f <file_path> -limit <number> -of <output_folder>
Argument | Description |
---|---|
-f |
Path to the file containing parameters. |
-limit |
Number of parameters per output file. |
-of |
Output folder and mode. Options: paramjson , paramhtml , paramgethtml , paramxml , parammultipart . |
python3 convert.py -f params.txt -limit 200 -of paramjson
- Input:
params.txt
- Output: Files in the
paramjson
folder, e.g.,1.json
,2.json
.
python3 convert.py -f params.txt -limit 200 -of paramhtml
- Input:
params.txt
- Output: Files in the
paramhtml
folder, e.g.,1.txt
,2.txt
.
python3 convert.py -f params.txt -limit 200 -of paramgethtml
- Input:
params.txt
- Output: Files in the
paramgethtml
folder, e.g.,1.txt
,2.txt
.
python3 convert.py -f params.txt -limit 200 -of paramxml
- Input:
params.txt
- Output: Files in the
paramxml
folder, e.g.,1.xml
,2.xml
.
python3 convert.py -f params.txt -limit 200 -of parammultipart
- Input:
params.txt
- Output: Files in the
parammultipart
folder, e.g.,1.txt
,2.txt
.
- File Not Found:
- If the parameter file does not exist, the script will display an error message.
- Empty File:
- If the parameter file is empty, the script will terminate with a descriptive error.
- Invalid Output Directory:
- The script will attempt to create the output directory if it does not exist.
- JSON/HTML/XML/Multipart Generation Errors:
- The script will handle and display any errors during file generation.