Decode json and use proxy on request

0

I have a proxy api with return in json.

Return of the proxy api (example):

    {
    "proxy": "170.79.201.54:20183",
    "ip": "170.79.201.54",
    "port": "20183",
    "connectionType": "Residential",
    "type": "elite",
    "lastChecked": 1526780653,
    "get": true,
    "post": true,
    "cookies": true,
    "referer": true,
    "userAgent": true,
    "city": "unknown",
    "state": "unknown",
    "country": "BR",
    "randomUserAgent": "Mozilla\/5.0 (compatible MSIE 9.0 Windows NT 6.0 Trident\/5.0 SLCC1 .NET CLR 2.0.50727 Media Center PC 5.0 .NET CLR 3.5.30729 .NET CLR 3.0.30729",
    "threadsAllowed": 50
}

Note: The proxy changes every request

I want to get a new api proxy for every request (get), and use it on my curl / request (post) ...

response = r.post(url, proxies=proxies) 

Resolution:

I was able to import the "json" module

import requests as r
import json

response1 = r.get('http://api...')

gotcha = response1.json()
sock = gotcha.get("proxy")
print(sock)
    
asked by anonymous 20.05.2018 / 04:20

0 answers