Instapy: ๏ฟฝ Symbol at the end of every comment like #631

Created on 11 Feb 2018  ยท  9Comments  ยท  Source: timgrossmann/InstaPy

Expected Behavior

Commenting without diamond question mark.

Current Behavior

Every comment has a question mark in a diamond. ๏ฟฝ

Possible Solution (optional)

InstaPy configuration

import sys
import os
from instapy import InstaPy
use_firefox=True
session = InstaPy(username='username', password='password', nogui=True, headless_browser=True, use_firefox=True, page_delay=25)
session.login()
session.set_do_comment(enabled=True, percentage=25)
session.set_comments([u'Text1! ๐Ÿ‘Œ๐Ÿป',u'Text2 ๐Ÿฅƒ',u'๐Ÿ˜๐Ÿ˜๐Ÿ˜',u'๐Ÿ‘๐ŸŒž',u'๐Ÿ‘Œ๐Ÿ‘Œ',u'๐Ÿฅƒ๐Ÿฅƒ๐Ÿ˜๐Ÿ‘',u'๐Ÿฅƒ๐Ÿ‘๐Ÿ˜„'])
session.set_do_follow(enabled=True, percentage=100, times=3)
session.set_ignore_users(['username'])
session.set_dont_like(['bla', 'bla2', 'bla3', 'bla4', 'bla5'])
session.like_by_tags(['#tag1','#tag2','#tag3','#tag4'], amount=30)
session.unfollow_users(amount=500, onlyInstapyFollowed = True, onlyInstapyMethod = 'FIFO', sleep_delay=600)
session.end()

Running environment:
Raspberry Pi3 (Jessie Lite)
Python 3.4.3
Configfile UTF-8-BOM with UNIX LF

Most helpful comment

@Venni27
You've encoded rand_comment as @keusta said, but in other place in the same function, it is being encoded again which is making the problem

logger.info("--> Commented: {}".format(rand_comment.encode('utf-8')))

Encode it in either one place, since you will encode it in line 38 (_to prevent that symbol from appearing_), the line above should be

logger.info("--> Commented: {}".format(rand_comment))

All 9 comments

same here, input > ([u' :punch: ', u' ๐Ÿ’ฏ ', u' :bomb: :bomb: :bomb: '])
same result ๐Ÿ˜ฌ๏ฟฝ with or without space

i had previous problems with file encoding iso-8859-15 by defaut maybe the editor

i try with session.set_comments([u':fire: ', u'\u2764']) with unicode limited to 4 but still got this at the end of each comment../

๏ฟฝ

Up !
After another try, the ๏ฟฝ symbol appears also at the end of each comment in simple text without any emoji..
If anyone have an idea where to search to fix this problem..

No news regarding this?
Do the others have not such a problem?

@Venni27 fixed yead thx to @uluQulu
in comment_util.py
find and replace
rand_comment = (choice(comments).format(username))
with
rand_comment = (choice(comments).format(username)).encode('utf-8')
it works for me

Thanks for he hint. Will try that tomorrow evening.

Sadly for me it is not working.
I changed line 38 to this:
rand_comment = (choice(comments).format(username)).encode('utf-8')

But that shows the error:
File "/opt/InstaPy/instapy/comment_util.py", line 66, in comment_image logger.info("--> Commented: {}".format(rand_comment.encode('utf-8'))) UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 0: ordinal not in range(128)

@Venni27
You've encoded rand_comment as @keusta said, but in other place in the same function, it is being encoded again which is making the problem

logger.info("--> Commented: {}".format(rand_comment.encode('utf-8')))

Encode it in either one place, since you will encode it in line 38 (_to prevent that symbol from appearing_), the line above should be

logger.info("--> Commented: {}".format(rand_comment))

Great hint.
Its now working again!
Thank you!!!

Was this page helpful?
0 / 5 - 0 ratings