curlpyconvert
A command-line tool to convert cURL commands into Python code for Grab or Context frameworks.
Installation
Install using pip:
pip install curlpyconvert
Or install from source:
git clone https://github.com/tadeasf/curlpyconvert.git
cd curlpyconvert
rye sync
Usage
Command Line
-
Copy your cURL command to clipboard
-
Run one of these commands:
# Interactive mode - will ask you to choose framework curlpyconvert # Or specify framework directly curlpyconvert -f grab # For Grab framework curlpyconvert -f context # For Context framework # Show output instead of copying to clipboard curlpyconvert -f grab -s
-
The converted Python code will be automatically copied to your clipboard (unless -s flag is used)
Example
Input (in clipboard):
bash
curl 'https://api.example.com/data' \
-H 'accept: application/json' \
-H 'cookie: session=abc123' \
-H 'user-agent: Mozilla/5.0'
Output (for Grab framework):
def method_name(self):
self.g.setup(cookies={
'session': 'abc123',
})
self.g.setup(headers={
'accept': 'application/json',
'user-agent': 'Mozilla/5.0',
})
# URL: https://api.example.com/data
Output (for Context framework):
def method_name(self):
self.context.cookies.update({
'session': 'abc123',
})
self.context.headers.update({
'accept': 'application/json',
'user-agent': 'Mozilla/5.0',
})
# URL: https://api.example.com/data
Features
- Converts cURL commands to Python code
- Supports both Grab and Context frameworks
- Extracts and formats:
- Cookies
- Headers
- URL
- POST data (if present)
- Uses clipboard for easy copy-paste workflow
- Interactive framework selection
- Rich terminal output with syntax highlighting
Requirements
- Python 3.10 or higher
- Dependencies (automatically installed):
- pyperclip
- typer
- rich
- six
Development
-
Clone the repository:
git clone https://github.com/tadeasf/curlpyconvert.git cd curlpyconvert
-
Install development dependencies:
rye sync # or: pip install -e ".[dev]"
-
Run tests:
rye run pytest # or: pytest
-
Build the package:
rye build # Creates dist/ directory with wheel and tar.gz
-
Publish to PyPI:
rye publish # Uploads to PyPI
License
GPL 3.0
Author
tadeasf business@tadeasfort.com
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Issues
If you find any bugs or have feature requests, please create an issue on GitHub.
Test
From project root: rye run pytest # If using Rye pytest # If installed in development mode with pip
- With coverage:
rye run pytest --cov=curlpyconvert
-
Specific test file: pytest src/curlpyconvert/test/test_curl_parser.py
-
Build rye build # Creates dist/ directory with wheel and tar.gz
-
Publish to PyPI rye publish
Metadata
Release files for curlpyconvert 4.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| curlpyconvert-4.1.3.tar.gz | 11.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| curlpyconvert-4.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.6 kB
Release files / curlpyconvert-4.1.3.tar.gz
| Download URL | curlpyconvert-4.1.3.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13b7426fef2d905d79cb66df8b398708cb5322770ebddfa778f70276d4994e4e
|
|
BLAKE2b-256 checksum How to use checksums |
e54d7a5c0466b5faa1abd7edb0da6d08d3273109eb07f4f61a8a2289abc1b3c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Release files / curlpyconvert-4.1.3-py3-none-any.whl
| Download URL | curlpyconvert-4.1.3-py3-none-any.whl |
|---|---|
| Size | 15.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1189a5c29aef8ed6e81c9175526106898c36aec2d2743f09eb2f05b8537baf57
|
|
BLAKE2b-256 checksum How to use checksums |
96f649b96bda9317fac187260eb32495ea7a2f33ebd749ecdcab39db3c595faa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Security for curlpyconvert 4.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.