I was not lucky with both of the approaches listed here. Both of them lead to the following error:
pycurl.error: (23, 'Failed writing body (0 != 108)')
According to the documentation, both lambda x: None and devnull.write should be good options:
The WRITEFUNCTION callback can return the number of bytes written . If this number is not equal to the size of the byte string, this means an error, and libcurl will abort the request. Returning No is an alternative way of indicating that the callback destroyed the entire string passed to it and therefore succeeded.
http://pycurl.sourceforge.net/doc/callbacks.html#WRITEFUNCTION
However, in my project, I had to do the following to fix this problem:
c.setopt(pycurl.WRITEFUNCTION, lambda bytes: len(bytes))
In other words, it was not necessary to return the number of bytes recorded during the scan. devnull.write really returns the number of bytes written, but I have not looked at that. Perhaps there is a problem with bytes and strings.
Please note that I am using Python 3. I assume this is not the case with Python 2.
href_
source share