프로젝트
GitHub에서 보기
spulec/uncurl
소개
curl 요청을 python-requests로 변환하는 라이브러리입니다.
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalUncurl - Converting curl requests to python-requests
In a nutshell
Uncurl is a library that allows you to convert curl requests into python code that uses Requests. Since the Chrome network inspector has a nifty "Copy as cURL", this tool is useful for recreating browser requests in python.
When you don't pass any arguments to uncurl, it will use whatever is in your clipboard as the curl command.
Example
$ uncurl "curl 'https://pypi.python.org/pypi/uncurl' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Cookie: foo=bar;' -H 'Connection: keep-alive' --compressed"
requests.get("https://pypi.python.org/pypi/uncurl", headers={
"Accept-Encoding": "gzip,deflate,sdch",
"Accept-Language": "en-US,en;q=0.8",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
}, cookies={
"foo": "bar",
})
The underlying API:
import uncurl
print(uncurl.parse("curl 'https://pypi.python.org/pypi/uncurl' -H 'Accept-Encoding: gzip,deflate,sdch'"))
prints the string
'requests.get("https://pypi.python.org/pypi/uncurl", headers={
"Accept-Encoding": "gzip,deflate,sdch",
})'
You can also retrieve the components as python objects:
>>> import uncurl
>>> context = uncurl.parse_context("curl 'https://pypi.python.org/pypi/uncurl' -H 'Accept-Encoding: gzip,deflate,sdch'")
>>> context.url
https://pypi.python.org/pypi/uncurl
>>> context.headers
OrderedDict([('Accept-Encoding', 'gzip,deflate,sdch')])
On Mac OS, you can also pipe input to uncurl:
pbpaste | uncurl
Install
$ pip install uncurl
관련 프로젝트 살펴보기
불러오는 중…
