E
E
EGORIKEBOLIK2020-01-01 10:25:33
Python
EGORIKEBOLIK, 2020-01-01 10:25:33

How to get the number of community subscribers using vk api?

I can not figure out how to get the number of subscribers of the group. Can I, not being a group administrator, get this information using groups.getById?
The code:

session = vk.Session(access_token=token)
vk_api = vk.API(session)
apivers = 5.126

def get_content():
    name = input("Введите название групп: ")
    count = int(input("Введите кол-во групп: "))
    pybl = vk_api.groups.search(q=name, type="group", v=apivers, city_id=73, count=count)    #Поиск групп по параметрам
    
    url = "https://vk.com/"

    number = pybl["items"]    
    print(pybl)
    print("Количество найденных групп:",len(number))
    print("-"*40)

    
    zero = -1
    short = pybl['items'][zero]["screen_name"]
    ids = pybl['items'][zero]['id']
    members = vk_api.groups.getbyid(group_id = ids, v = apivers, fields = "members_count")  #Здесь возникает ошибка
    print("Ссылки на группы:\n")
    
    for i in range (len(number)):
        
        zero += 1
        ids = pybl['items'][zero]['id']
        short = url + pybl['items'][zero]["screen_name"]
        print(short, "\t id:",ids )
    print(zero +1)
    
    
get_content()


Mistake:
vk.exceptions.VkAPIError: 3. Unknown method passed. request_params = {'method': 'groups.getbyid', 'oauth': '1', 'group_id': '98888771', 'v': '5.126', 'fields': 'members_count'}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
ZIK1337, 2020-01-01
@EGORIKEBOLIK

https://vk.com/dev/groups.getMembers

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question