качаю фотки с контакта
вместо 641 качает 300 с чем то
хотя в консоль выводит и номер и ссылку
почему так?
import os
import vk
import requests
import datetime
import time
user = '1'
vkapi = vk.API(app_id, login, pass, access_token = ********)
user_info = vkapi.users.get(user_ids = user)
name = str(user_info[0]['first_name'])+' '+str(user_info[0]['last_name'])
def timestamptodate(timestamp):
return datetime.datetime.fromtimestamp(timestamp).strftime('%Y.%m.%d-%H.%M')
def save_photo(img, date):
if (os.path.exists('C:\\Users\\home\\Desktop\\vk_photo\\'+name) == False):
os.makedirs('C:\\Users\\home\\Desktop\\vk_photo\\'+name)
f = requests.get(img)
foto = open('C:\\Users\\home\\Desktop\\vk_photo\\'+name+'\\'+date+'.jpg', 'wb')
foto.write(f.content)
foto.close()
def get_photo(n):
return vkapi.photos.getAll(owner_id=user, photo_sizes=0, rev=0, count=200, offset=n)
def parce_photo():
n = 0
y = 0
while (n<=800):
photo = get_photo(n)
for i in photo['items']:
key = i.keys()
max = 0
for x in key:
if x.startswith('photo_')and(int(x[6:])>max):
max = int(x[6:])
y = y+1
img = i['photo_'+str(max)]
date = timestamptodate(i['date'])
print(y, i['photo_'+str(max)])
time.sleep(1)
save_photo(img, date)
n += 200
parce_photo()