简体   繁体   中英

Python RESTful client like Guzzle from PHP

What Python library provides RESTful client interface like:

client = Client(
    base_url="http://example.com/api/1/", auth=("user", "password"),
    cookie=cookielib.FileCookieJar('cookie-file'))
result = client.get('group', params={"groupname": "some_group", "expand": "users"})
result.json()

Not exactly like that, but you likely want requests

edit: since you want to ommit your base URL, try something like this:

base_url = "http://example.com/"
def requests_get(url, *args, **kwargs):
    return requests.get(base_url + url,*args,**kwargs)

An alternative solution is to subclass requests.Session as shown in this answer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM