class whoLike(QtWidgets.QMainWindow, who_likes.Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.whoLiked)
self.pushButton_2.clicked.connect(self.exitApp)
self.listWidget.itemClicked.connect(self.selectionChanged)
def selectionChanged(self, item):
a = ("{}".format(item.text()))
print(a)
webbrowser.open(a)
def exitApp(self):
self.close()
def whoLiked(self):
self.listWidget.clear()
response = requests.get(
'https://api.vk.com/method/friends.get?access_token=%s&v=%s&order=name' % (access_token, version))
data = response.json()
print(data)
data_fil = data['response']["items"]
len_check = len(data_fil)
print(data_fil)
mass_likes = []
i = 0
check_x = 0
for filter_data in data_fil:
response_posts = requests.get('https://api.vk.com/method/wall.get?access_token=%s&v=%s&owner_id=%s' % (
access_token, version, filter_data))
data_posts = response_posts.json()
check_x += 1
self.label_5.setText(str(check_x) + '/' + str(len_check))
i += 1
if i >= 7:
# Ждем 3 секунды
loop = QEventLoop()
QTimer.singleShot(3000, loop.quit)
loop.exec()
i = 0
else:
try:
post = data_posts['response']['items']
print(post)
for posts in post:
likes_posts = posts['likes']['user_likes']
if likes_posts == 1:
user_id = posts['owner_id']
id_post = posts['id']
url = 'https://vk.com/id%s?w=wall%s_%s' % (user_id, user_id, id_post)
mass_likes.append(url)
self.listWidget.addItem(url)
print(url)
else:
continue
except:
print('User was deleted or banned')