Download the files attached to the Toloker responses.
Connect the Toloka-Kit library to your script.
import toloka.client as toloka
Replace the sample API key with your own one.
toloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', '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.download_attachment('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('PlaceYourRealApiKey_Here', 'PRODUCTION')with open(attachment_id + '.jpg', 'wb') as attachment_file: toloka_client.download_attachment('fr.5867be74-249b-4264-9ed0-aa5d4c201846', out=attachment_file)
Last updated: February 7, 2023