Answer the question
In order to leave comments, you need to log in
SyntaxError: invalid syntax in vk_api, help?
I wrote an autostatus for the VK page, took a piece of code from another person that determines how many likes on ava and displays it in status.
Error:
Part of code:
import vk_api
import time
import json
from urllib import request
import requests
token = "my_token"
while True:
vk = vk_api.VkApi(token)
on = vk.method("friends.getOnline")
counted = len(on)
vk.method("status.set", {"text": " Друзей онлайн: " + str(counted)})
def startStatus():
try:
getLikes = requests.get(f"https://api.vk.com/method/photos.get?album_id=profile&rev=1&extended=1&count=1&v=5.95&access_token={token}").json()
getLikes = getLikes["response"]["items"][0]["likes"]["count"]
except IndexError:
print("У профиля отсутсвует аватар или лайки.")
getLikes = 0
statusSave = (" Лайков на аве: " + str(getLikes).format(getLikes))
statusOut = requests.get(f"https://api.vk.com/method/status.set?text={statusSave}&v=5.95&access_token={token}").json()
if statusOut.get("error", None):
print(f"Не удалось обновить статус сервер вернул неверный код ответа: {statusOut}")
else:
print(f"Статус был обновлен")
while True:
startStatus()
time.sleep(30)
Answer the question
In order to leave comments, you need to log in
So go version of python that doesn't know how to f-string yet
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question