I need to get the result of dns resolution of the input URL using PyCurl. Following is the code:
buf = cStringIO.StringIO()
c = pycurl.Curl()
c.setopt(c.URL, url)
c.setopt(c.WRITEFUNCTION, buf.write)
c.setopt(c, c.CURL_IPRESOLVE_WHATEVER, host)
c.setopt(c.HTTPHEADER, ["User-Agent: "])
# c.setopt(c.CONNECTTIMEOUT, 20)
c.setopt(c.TIMEOUT, 15)
c.setopt(c.FOLLOWLOCATION, True)
c.perform()
I have searched the Pycurl Documentation and didn't find a good answer.
I have searched in the documentation of Libcurl and found
getinfo()
function which is described in this link : https://curl.haxx.se/libcurl/c/curl_easy_getinfo.html But be careful this is for C and when using it in Pycurl you have to convert constants using this link : https://github.com/pycurl/pycurl/blob/master/src/module.c#L1134as the answer to retrieve the IP address of a URL following line should be added: