Сам код:
import asyncio
from vkbottle import API
import json
import os
import requests
token = "мой"
async def main():
api = API("мой")
group_name = input("Введите название группы: ")
url = f"https://api.vk.com/method/wall.get?domain={group_name}&count=40&access_token={token}&v=5.131"
req = requests.get(url)
src = req.json()
# проверяем существует ли директория с именем группы
if os.path.exists(f"{group_name}"):
print(f"Директория с именем {group_name} уже существует!")
else:
os.mkdir(group_name)
# сохраняем данные в json файл, чтобы видеть структуру
with open(f"{group_name}/{group_name}.json", "w", encoding="utf-8") as file:
json.dump(src, file, indent=4, ensure_ascii=False)
# собираем ID новых постов в список
fresh_posts_id = []
global posts
posts = src["response"]["items"]
for fresh_post_id in posts:
fresh_post_id = fresh_post_id["id"]
fresh_posts_id.append(fresh_post_id)
if not os.path.exists(f"{group_name}/exist_posts_{group_name}.txt"):
print("Файла с ID постов не существует, создаём файл!")
with open(f"{group_name}/exist_posts_{group_name}.txt", "w") as file:
for item in fresh_posts_id:
file.write(str(item) + "\n")
for post in posts:
post_id = post["id"]
await api.wall.create_comment(owner_id=-47092692, post_id=post_id, message="ком")
if __name__ == '__main__':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
текст ошибки:
Traceback (most recent call last):
File "C:\Users\sasha\OneDrive\Рабочий стол\Новая папка (7)\s.py", line 156, in <module>
asyncio.run(main())
File "C:\Users\sasha\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\sasha\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\Users\sasha\OneDrive\Рабочий стол\Новая папка (7)\s.py", line 152, in main
await api.wall.create_comment(owner_id=-47092692, post_id=post_id, message="ком")
File "C:\Users\sasha\AppData\Local\Programs\Python\Python310\lib\site-packages\vkbottle_types\methods\wall.py", line 94, in create_comment
response = await self.api.request("wall.createComment", params)
File "C:\Users\sasha\AppData\Local\Programs\Python\Python310\lib\site-packages\vkbottle\api\api.py", line 74, in request
return await self.validate_response(method, data, response) # type: ignore
File "C:\Users\sasha\AppData\Local\Programs\Python\Python310\lib\site-packages\vkbottle\api\api.py", line 98, in validate_response
response = await validator.validate(method, data, response, self) # type: ignore
File "C:\Users\sasha\AppData\Local\Programs\Python\Python310\lib\site-packages\vkbottle\api\response_validator\vk_api_error_validator.py", line 51, in validate
raise exception(**error)
TypeError: VKAPIError.__init__() got an unexpected keyword argument 'error_text'