MohanSha / InstaPy

📷 Instagram Bot - Like/Comment/Follow Automation Script
GNU General Public License v3.0
23 stars 9 forks source link

Using InstaPy / UnicodeEncodeError? #3

Open Rapid1898-code opened 2 years ago

Rapid1898-code commented 2 years ago

Hello - when using InstaPy with the following code i get an UnicodeEncodeError -

from dotenv import load_dotenv, find_dotenv
import os
from instapy import InstaPy
from importlib import reload

load_dotenv(find_dotenv())
INSTA_USER = os.environ.get("INSTA_USER")
INSTA_PW = os.environ.get("INSTA_PW")

session = InstaPy(username=INSTA_USER, 
                  password=INSTA_PW,
                  headless_browser= True)
session.login()
session.like_by_tags(["wien"], amount=1)

Error:

--- Logging error ---
Traceback (most recent call last):
  File "c:\users\polzi\appdata\local\programs\python\python39\lib\logging\__init__.py", line 1082, in emit
    stream.write(msg + self.terminator)
  File "c:\users\polzi\appdata\local\programs\python\python39\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u0308' in position 18868: character maps to <undefined>
Call stack:
  File "C:\Users\Polzi\Documents\DEV\Python-Diverses\InstaPy\exmplInstaPy.py", line 15, in <module>
    session.like_by_tags(["wien"], amount=1)
  File "C:\Users\Polzi\Documents\DEV\.venv\instapy\lib\site-packages\instapy\instapy.py", line 1980, in like_by_tags
    inappropriate, user_name, is_video, reason, scope = check_link(
  File "C:\Users\Polzi\Documents\DEV\.venv\instapy\lib\site-packages\instapy\like_util.py", line 618, in check_link
    logger.info("post_page: {}".format(post_page))
Message: "post_page: {'items': [{'taken_at': 1645977416, 'pk': 2782982736417357470, 'id': '2782982736417357470_10413942182', 'device_timestamp': 1645977415339, 'media_type': 8, 'code': 'CafJA3MM36e', 'client_cache_key': 'Mjc4Mjk4MjczNjQxNzM1NzQ3MA==.2', 'filter_type': 0, 'carousel_media_count': 3, 'carousel_media': [{'id': '2782982731744811142_10413942182', 
'media_type': 1, 'image_versions2': {'candidates': [{'width': 480, 'height': 480, 'url': 'https://scontent-vie1-1.cdninstagram.com/v/t51.2885-15/274838151_1964041973783269_2424138370886350601_n.jpg?stp=dst-jpg_e15_s480x480&_nc_ht=scontent-vie1-1.cdninstagram.com&_nc_cat=101&_nc_ohc=1nSF0m02QIkAX_rEjac&edm=AABBvjUBAAAA&ccb=7-4&ig_cache_key=Mjc4Mjk4MjczMTc0NDgxMTE0Mg%3D%3D.2-ccb7-4&oh=00_AT_GrkLy-zHx-sgYLaQcYMyyfmQ-TmqSCH9p87h0Xki3Ag&oe=62225C7C&_nc_sid=83d603', 'scans_profile': 'e15'}, {'width': 320, 'height': 320, 'url': 'https://scon
Traceback (most recent call last):
  File "C:\Users\Polzi\Documents\DEV\Python-Diverses\InstaPy\exmplInstaPy.py", line 15, in <module>
    session.like_by_tags(["wien"], amount=1)
  File "C:\Users\Polzi\Documents\DEV\.venv\instapy\lib\site-packages\instapy\instapy.py", line 1980, in like_by_tags
    inappropriate, user_name, is_video, reason, scope = check_link(
  File "C:\Users\Polzi\Documents\DEV\.venv\instapy\lib\site-packages\instapy\like_util.py", line 619, in check_link
    media = post_page[0]["shortcode_media"]
KeyError: 0

What can i do so this module is working?

Andrew-creator-art commented 2 years ago

boa noite.isto acontece a mesma coisa comigo. vou tentar reinstalar outra versão.