Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Pycurl follow redirects and extentions

From: Feilpe Restrepo via curl-and-python <curl-and-python_at_cool.haxx.se>
Date: Mon, 7 Dec 2020 20:57:19 -0500

Hi,

I have been searching without success about how to intercept location
redirect and allow or not to surf that page with pycurl.
I have the FOLLOWLOCATION set in True and the HEADERFUNCTION working, but
once the FOLLOWLOCATION is on, I can't stop a redirect.
The context is, I am making a crawler and some pages will have a redirect
in its headers but not in the body, so I want to validate that in the
extension of the new URL set in the location header there will be not
[.png, .jpg, etc.]

I think this is not really usual, but it's possible, so I want to avoid a
redirect to that type of content.

I know that I can filter by Content-Type image in the headers but at that
moment the page has sent the response and it will reside in the memory of
the device and I want to avoid that.

Best Regards :)

_at_Pfelilpe


_______________________________________________
https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2020-12-08