Giter Club home page Giter Club logo

curl2pyreqs's Introduction

curl2pyreqs

A library to convert curl to python requests file.

Requirement

Python >= 3.6

pyperclip >= 1.8.0

rich >= 9.13.0

On Linux, xclip or xsel needed:

sudo apt-get install xclip
or
sudo apt-get install xsel

Install

$ pip install curl2pyreqs

Usage

Use as binary

  • Export curl request file to python script.
$ curl2pyreqs -F example.curl
Convertion Finished.
Please open example.py to check the code.
  • Convert curl request in the clipboard and paste the requests code back
$ curl2pyreqs
Convertion Finished.
Now requests code is copyed in your clipboard.

Use by importing

  • Convert a curl string to python-requests, copyed from Chrome or Firefox:
>>> from curl2pyreqs.ulti import parseCurlString
>>> output = parseCurlString("""curl -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'accept-language: en-US,en;q=0.5' --compressed -H 'upgrade-insecure-requests: 1' -H 'te: trailers' https://pypi.org/""")
>>> print(output)
  • Convert curl file stream to python-requests, copyed from Chrome or Firefox:
>>> from curl2pyreqs.ulti import parseCurlFile
>>> output = parseCurlFile('./example.curl')
>>> print(output)

README_CN

中文版说明

curl2pyreqs's People

Contributors

knightz1224 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.