0

I am currently translating code from PHP:

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 120);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TCP_NODELAY, 1);
    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); 

How do I set these variables in python's requests?

This is what i have so far

output = requests.post(url, headers=headers)

Tinker
  • 4,165
  • 6
  • 33
  • 72

1 Answers1

0

You have to do something like this:

c = pycurl.Curl()

c.setopt(c.URL, url)
c.setopt(c.WRITEFUNCTION, buffer.write)
c.setopt(c.USERPWD,USER+':'+PASSWORD)
c.setopt(c.VERBOSE, True)
c.setopt(c.HEADERFUNCTION, header_function)
c.perform()
Pawan
  • 1,537
  • 1
  • 15
  • 19