A
A
Alexey Al2019-06-15 14:53:01
Python
Alexey Al, 2019-06-15 14:53:01

Is it possible to download links to Disk from Yandex.Mail using the API?

I receive letters from Yandex mail users, where some of the pictures are attached directly to the letter, and some are in the form of links to Yandex.Disk
For example:
https://yadi.sk/mail?hash=cDPZbg71i2Bo80Y7kUnZyQ5W...
Is it possible to download such links from python?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2019-06-15
@palkokrut

Yes, you can. Here is the documentation https://tech.yandex.ru/disk/api/reference/public-d...
In short, you need to take the received public link and process it through urlencode. Get:
Then send a request with the encoded public url as the public_key:
In response, get json with a direct link to download the file:

{"href":"https://downloader.disk.yandex.ru/disk/f9b20c3dbd34328c52b62dde0bc0af296c9744333cb39c4fd64e9715d8c895f1/5d0550ed/Gl5hixkLDPWPTXhYLxRGzwIU6SE6zbIztnJBcyBcjxKgxsJiX5ITcwuvga79wVd1Ag1LkmeJkjhEVwtWAwsZHA%3D%3D?uid=0&filename=IMG_1890.JPG&disposition=attachment&hash=cDPZbg71i2Bo80Y7kUnZyQ5WPKM685Cubv3A8j3rPPg%3D%3A&limit=0&content_type=image%2Fjpeg&fsize=5995787&hid=0b77247ae14e2c4d8933a22b211b6485&media_type=image&tknv=v2","method":"GET","templated":false}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question