Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- import sys
- zapros = 'DSC'
- auth = '+++++++' #access_token
- off = 0
- requests.packages.urllib3.disable_warnings()
- r = requests.get('https://api.vk.com/method/docs.search?q=%s&count=1&access_token=%s&v=5.60' % (zapros, auth))
- json123 = json.loads(r.text)
- if 'error' in json123:
- print json123['error']['error_msg']
- else:
- if json123['response']['count'] > 0:
- print 'Total:', json123['response']['count']
- while len(json123['response']['items']) > 0:
- r = requests.get('https://api.vk.com/method/docs.search?q=%s&count=100&offset=%i&access_token=%s&v=5.60' % (zapros, off, auth))
- json123 = json.loads(r.text)
- for i in json123['response']['items']:
- print 'Owner:', i['owner_id'], '\r\nTitle:', i['title'], '\r\nDownloading...',
- sys.stdout.flush()
- try:
- doc = requests.get(i['url'])
- fl = open(i['title'], 'wb')
- fl.write(doc.content)
- fl.close()
- print 'OK\r\n'
- except KeyboardInterrupt:
- raise KeyboardInterrupt
- except:
- print 'Fail\r\n'
- continue
- off += 100
- else:
- print 'Not found:', zapros
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement