0

I have been working with curl request (from bash)

/usr/bin/curl -L -k -u admin:admin -X GET 'https://localhost/test/123/123'

How can I translate this request to the pycurl code, and implement it through python, options are important as it is REST API.

The options that I used in curl are

-k for insecure(ssl bypass)

-L redirect

-X request GET

Thanks,

Tiz
  • 1
  • 1

1 Answers1

0

There is documentation that you can read for information. It references CURL's setopt options. If you read the documentation you'd figure out what you want to know, but I assume you're asking here because you want someone else to read it for you.

import pycurl

c = pycurl.Curl()
c.setopt(c.URL, "https://localhost/test/123/123")
c.setopt(c.SSL_VERIFYPEER, False) # -k
c.setopt(c.FOLLOWLOCATION, True) # -L
c.setopt(c.HTTPGET, True) # -X
c.perform()
Conner
  • 30,144
  • 8
  • 52
  • 73