D
D
DamskiyUgodnik2020-05-01 23:57:15
Python
DamskiyUgodnik, 2020-05-01 23:57:15

How to put a restriction on the type of content received in curl?

Hello!

The essence of the task is to make a restriction on obtaining data from a specific URL, namely, that the size of the downloaded data is no more than a given value and there is a restriction on the type (for example, HTML). I am using pycurl.

The first part of the task was solved through the "MAXFILESIZE" parameter (if the file is larger than a certain size, then an exception is thrown). But how to make an exception fall out if, for example, the downloaded data is not found in the dock (the dock means this one https://curl.haxx.se/libcurl/c/curl_easy_setopt.html ).

So far, only getting the headers (without the data itself) comes to mind, then processing them and getting the data itself with the second request, but I suppose there is a more elegant solution, by analogy with the file size.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question