Download the files attached to the Toloker responses.
Connect the Toloka-Kit library to your script.
import toloka.client as toloka
Replace the sample OAuth token with your own one.
toloka_client = toloka.('AQC2AGAJgyNSA8CtpdO9MWy_QEB6s6kDjHUoElE', 'PRODUCTION');
Find out the ID and the extension of the file attached to the Toloker response which you want to download. Then download this file calling the download_attachment()
method.
# Use the standard 'with open()' Python method with the 'wb' (write + binary) parameters specified
with open(attachment_id + '.jpg', 'wb') as attachment_file:
toloka_client.('fr.5867be74-249b-4264-9ed0-aa5d4c201846', out=attachment_file)
The attachment will be saved to the specified out
destination.
import toloka.client as tolokatoloka_client = toloka.TolokaClient('AQC2AGAJgyNSA8CtpdO9MWy_QEB6s6kDjHUoElE', 'PRODUCTION')with open(attachment_id + '.jpg', 'wb') as attachment_file: toloka_client.download_attachment('fr.5867be74-249b-4264-9ed0-aa5d4c201846', out=attachment_file)