OlegYurchik / pyInstagram

This is a simple and easy-to-use library for interacting with the Instagram. The library works through the web interface of the Instagram and does not depend on the official API
MIT License
232 stars 49 forks source link

Не работает асинхронный код #38

Closed Disaxy closed 5 years ago

Disaxy commented 5 years ago

Добрый день, я новичок в асинхронном программировании подскажите что я не так делаю, код выдает ошибку.

Disaxy commented 5 years ago

`from instaparser.agents import AsyncAgent from instaparser.entities import Media, Account import asyncio

async def get_media(account): agent = AsyncAgent() account = Account(account) media, pointer = await agent.get_media(account) print(str(media))

event_loop = asyncio.get_event_loop() event_loop.run_until_complete(get_media('sazonovi')) event_loop.close()`

`Traceback (most recent call last): File "D:\YandexDisk\project\asyncio_bot\venv\lib\site-packages\instaparser\agents.py", line 708, in get_request response = await self.session.get(*args, **kwargs) AttributeError: 'AsyncAgent' object has no attribute 'session'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "inst_parser.py", line 14, in event_loop.run_until_complete(get_media('sazonovi')) File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\asyncio\base_events.py", line 568, in run_until_complete return future.result() File "inst_parser.py", line 9, in get_media media, pointer = await agent.get_media(account) File "D:\YandexDisk\project\asyncio_bot\venv\lib\site-packages\instaparser\agents.py", line 431, in get_media data = await self.update(obj, settings=settings) File "D:\YandexDisk\project\asyncio_bot\venv\lib\site-packages\instaparser\agents.py", line 395, in update response = await self.get_request(query, **settings) File "D:\YandexDisk\project\asyncio_bot\venv\lib\site-packages\instaparser\agents.py", line 711, in get_request raise InternetException(exception) instaparser.exceptions.InternetException: 'AsyncAgent' object has no attribute 'session'`

OlegYurchik commented 5 years ago

Для содания асинхронного агента нужно использовать метод create