Needed from a specified list of links save only those, that return .doc or .pdf file, while its size should be no larger than 3 MB. Solved this problem is quite simple: Filter the results by the required content-type: application/msword or application/pdf Scraping content-lenght - is the size of the returned file Filter the results by size - no more than 3 MB Download only headers - for saving time *What are MIME-types: http://www.freeformatter.com/mime-types-list.html#mime-types-list **If you do not turn on option Read only headers and output to result $data, generating unique file names, you can organize downloading of files certain formats and sizes. Spoiler: Code for import Code: eyJwcmVzZXQiOiJjb250ZW50IiwidmFsdWUiOnsicHJlc2V0IjoiY29udGVudCIs InBhcnNlcnMiOltbIk5ldDo6SFRUUCIsImRlZmF1bHQiLHsidHlwZSI6Im92ZXJy aWRlIiwiaWQiOiJnb29kQ29kZSIsInZhbHVlIjoyMDB9LHsidHlwZSI6Im92ZXJy aWRlIiwiaWQiOiJmb3JtYXRyZXN1bHQiLCJ2YWx1ZSI6IiRxdWVyeVxcbiJ9LHsi dHlwZSI6ImZpbHRlciIsInJlc3VsdCI6ImhlYWRlcnMiLCJmaWx0ZXJUeXBlIjoi cmVtYXRjaCIsInZhbHVlIjoiYXBwbGljYXRpb25cXC9wZGZ8YXBwbGljYXRpb25c XC9tc3dvcmQiLCJvcHRpb24iOiJpIn0seyJ0eXBlIjoiY3VzdG9tUmVzdWx0Iiwi cmVzdWx0IjoiaGVhZGVycyIsInJlZ2V4IjoiY29udGVudC1sZW5ndGguKz8oXFxk KykiLCJyZWdleFR5cGUiOiIiLCJyZXN1bHRUeXBlIjoiZmxhdCIsImFycmF5TmFt ZSI6IiIsInJlc3VsdHMiOlsibGVuIl19LHsidHlwZSI6ImZpbHRlciIsInJlc3Vs dCI6ImxlbiIsImZpbHRlclR5cGUiOiI8IiwidmFsdWUiOiIzMTQ1NzI4Iiwib3B0 aW9uIjoic2VucyJ9LHsidHlwZSI6Im92ZXJyaWRlIiwiaWQiOiJvbmx5aGVhZGVy cyIsInZhbHVlIjp0cnVlfV1dLCJyZXN1bHRzRm9ybWF0IjoiJHAxLnByZXNldCIs InJlc3VsdHNTYX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