Search
Write a publication
Pull to refresh
0
0
Send message
есть типа такого скрипта, только для скачивания сохраненных картинок, но там лимит стоит на 1000 картинок за одну сессию, если кто знает там есть метод offset он позволяет скачивать больше 1000 картинок за раз как его использовать

import requests
import io
import json

token = '******'
count = 2476
offset = 1000


def download(url):
    r = requests.get(url, stream=True)
    filename = url.split('/')[-1]

    with open(filename, 'bw') as file:
        for chunk in r.iter_content(4096):
            file.write(chunk)


def write_json(data):
    with open('response_2.json', 'w') as file:
        json.dump(data, file, indent=2, ensure_ascii=False)


def get_largest(size_dict):
    weight = {'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 'm': 10, 'x': 20, 'y': 30, 'z': 40, 'w': 50}
    size_dict['type'] = weight[size_dict['type']]
    return size_dict['type']


def main():
    # photos = json.load(open('response_2.json'))['response']['items']

    # for photo in photos:
    # sizes = photo['sizes']

    # max_size_url = max(sizes, key=get_largest)['src']
    # download(max_size_url)

    r = requests.get('https://api.vk.com/method/photos.get',
                     params={'owner_id': '*****',
                             'v': '5.52',
                             'access_token': token,
                             'album_id': 'saved', 'photo_sizes': True, 'count': count, 'offset': offset})
    write_json(r.json())




if __name__ == '__main__':
    main()

Information

Rating
Does not participate
Registered
Activity