Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import time
- import csv
- def take_1000_posts():
- token = 'b182981a358908827c5332f0785085c7cc1c535cf4b05e2fcec3ac9ebcfdf00d273a1895139329b70c75c'
- version = 5.103
- count = 100
- offset = 0
- all_posts = []
- response = requests.get('https://api.vk.com/method/users.get?',
- params={
- 'access_token': token,
- 'v': version,
- 'user_ids': 552656501,
- 'fields': 'id, first_name, last_name, maiden_name, sex, about, activities, city, domain, \n'
- 'career, city, connections, contacts, country, education, has_mobile,\n'
- 'interests, military,occupation, personal, quotes,relatives, \n'
- 'relation, schools, status, universities',
- }
- )
- data = response.json()['response']['items']
- for data_tek in data:
- id = data_tek['id']
- first_name = data_tek['first_name']
- last_name = data_tek ['last_name']
- maiden_name = data_tek['maiden_name']
- sex = data_tek['sex']
- about = data_tek['about']
- activities = data_tek['activities']
- city = data_tek['city']
- domain = data_tek['domain']
- career = data_tek['career']
- city = data_tek['city']
- connections = data_tek['connections']
- contacts = data_tek['contacts']
- country = data_tek['country']
- education = data_tek['education']
- has_mobile = data_tek['has_mobile']
- interests = data_tek['interests']
- military = data_tek['military']
- occupation = data_tek['occupation']
- personal = data_tek['personal']
- quotes = data_tek['quotes']
- relatives = data_tek['relatives']
- relation = data_tek['relation']
- schools = data_tek['schools']
- status = data_tek['status']
- universities = data_tek['universities']
- # time.sleep(0.5)
- # zapis v exl
- '''
- def file_writer(data):
- with open ('fit4life.csv','w') as file:
- a_pen = csv.writer(file)
- a_pen.writerow(('likes', 'body', 'url'))
- for post in data:
- try:
- if post ['attachments'][0]['type']:
- img_url = post['attachments'][0]['photo']['sizes'][-1]['url']
- else:
- img_url = 'pass'
- except:
- pass
- a_pen.writerow((post['likes']['count'], post['text'], img_url))
- file_writer(all_posts)
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement