Comments with escaped apostrophe are allowed and function
Comments with escaped apostrophe cause script to exit
session.set_comments([
u'I\'d rather not live like there isn\'t a God, then die and find out there really is - think about it #kendricklamar :fire: :collision: :fire: true dat {}',
u'You don\'t need dollars to make you feel like you have a place in this world #kendricklamar :dollar: :money_with_wings: it\'s true {}'
])
Error
raceback (most recent call last):
File "user-atxmusicvideos-hashtag-kendricklamar.py", line 48, in <module>
session.like_by_tags(['kendricklamar'], amount=46)
File "/Users/XXX/Documents/Code/InstaPy/instapy/instapy.py", line 1087, in like_by_tags
self.logfolder)
File "/Users/XXX/Documents/Code/InstaPy/instapy/comment_util.py", line 52, in comment_image
"arguments[0].value = '" + rand_comment + " ';", comment_input[0])
File "/Library/Python/2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 465, in execute_script
'args': converted_args})['value']
File "/Library/Python/2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/Library/Python/2.7/site-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected identifier
(Session info: chrome=66.0.3359.139)
(Driver info: chromedriver=2.38.552518 (183d19265345f54ce39cbb94cf81ba5f15905011),platform=Mac OS X 10.13.4 x86_64)
I'm more than happy to just use bad grammar and remove the apostrophe. Any tips on getting the script to run with an apostrophe in the comments would be really appreciated.
You all are the bomb. Great tool. Thank you.
hi @axlright,
It's an obvious result of a quote conflicting.
in comment_util.py file,
replace
"arguments[0].value = '" + rand_comment + " ';", comment_input[0])
with
"arguments[0].value = arguments[1];", comment_input[0], rand_comment+' ')
_now, it should work fine, regardless of the comment text_
Hey @uluQulu thanks so much for getting back. Still having similar problems after making the change you suggested and pulling the most recent commits from the repo.
Here's the error message:
Traceback (most recent call last):
File "user-atxmusicvideos-hashtag-leikeli47.py", line 47, in <module>
session.like_by_tags(['#leikeli47'], amount=247)
File "/Users/XXX/Documents/Code/InstaPy/instapy/instapy.py", line 1184, in like_by_tags
self.logfolder)
File "/Users/XXX/Documents/Code/InstaPy/instapy/comment_util.py", line 41, in comment_image
rand_comment = (choice(comments).format(username))
IndexError: tuple index out of range
and here's the settings:
session.set_relationship_bounds(enabled=True,
potency_ratio=-1.09,
delimit_by_numbers=True,
max_followers=2560,
max_following=9999,
min_followers=45,
min_following=47)
# actions
session.set_do_follow(enabled=True, percentage=74, times=1)
session.set_comments([
u'They \'bout to start a world war, I\'m just tryna practice peace #leikeli47 :microphone: :fire: true true {} :mask: :muscle:',
u'Real life here, Ain\'t no commercials or reruns, No DVRs to start over Once it\'s on, it\'s on #leikeli47 :fire: :collision: :fire: true true {} :mask: :muscle: :microphone:',
u'Give me 50 feet or better Matter fact give me better Because if you don\'t, the wolves behind me Tellin\' me Let me at \'em, Let me at \'em #leikeli47 :fire: :collision: :fire: true dat {} :mask: :muscle: :microphone:'
])
session.set_do_comment(enabled=True, percentage=68)
session.like_by_tags(['#leikeli47'], amount=247)
I'm wondering if the issue has to do with referencing the username with the {}
- I'm doing that without the @ just to make each comment technically unique and because it seems kinda weird and fun. I notice that some of the script failures happen when commenting on users that have a period in their Instagram username, though not always - sometimes it works with a username with a period. Let me try the same setup without the username {}
to try to isolate the issue.
THANKS!
Looks like this is all solved. I'm gonna mark this as closed. Thanks for your help!
Hey @axlright,
It's a pleasure.
But I couldn't really find out how that error could occur 馃,
IndexError: tuple index out of range
And I don't think it is related to the change I suggested.
Also thinks there must not be any problem either with using periods in usernames or having curly braces for python formatter
Could you solve that tuple index error, too?
BTW are you the Java guy from Slack working with search engines or my memory is wrong? xD
@uluQulu I often wake up very tired thinking I may be doing things in my sleep, but I am not (that I know of) a Java guy on Slack working with search engines. Let me check my bank account, though. I'll let you know if I am 馃槃
What I'm posting is some testing I'm doing with a personal project so I can get kinks worked out before going in for "real" projects.
I'm running similar functions every day. I'll ping you if I see anything funky come up related to IndexError: tuple index out of range
I haven't joined the Slack channel yet, but it's on my list. Is it a good community there?
I really appreciate all your work. One day if I get smart enough I'll work on contributing, even if just cleaning up old issue tickets 馃槈
Thank you very much @axlright, 馃寽 I got a terribly bad memory but I thought you are the one with the teacherman
username, anyways,
Yes, please, let me know if gets any update on that piece for good's sake! :)
_cos it has been a very puzzled situation for me, IndexError
out of tuple
range in such a clean code is very weird_
I saw your profile, you are doing very good and it's great to have such a dedicated programmer on the project!
Well yeah, Slack is truly a good spot for project specific discussions, at least it was, before I left.
That would be so good cos most of the issues are resolved but they remain open.
Hope you good promotions!
@axlright How did you fix this error? rand_comment = (random.choice(comments).format(username)) IndexError: tuple index out of range
@alexsmedile I'm not sure I follow. I do run lots and lots of scripts with comments. I've started storing comments in a common.py
file so I can re-use the most common comments across multiple scripts while still adding custom comments in every script.
Looks like this
in common.py
:
comments_general = [
u':fire:',
u':dizzy:',
u':bangbang:',
u':lollipop:',
u':lollipop::lollipop:',
u':pineapple:',
u':pineapple::pineapple:'
u':heart::heart:',
u':bangbang::pineapple:',
u':blush:',
u':zap::dizzy::collision::sparkles:',
u':raised_hands::heart_eyes_cat:',
]
Then in each instapy script file:
comments_custom = [
'looks like a great time!',
'someone\'s havin\' fun',
]
comments = comments_custom + common.comments_general
...
session.set_comments(comments)
Don't know if this is helpful.
Most helpful comment
Hey @uluQulu thanks so much for getting back. Still having similar problems after making the change you suggested and pulling the most recent commits from the repo.
Here's the error message:
and here's the settings:
I'm wondering if the issue has to do with referencing the username with the
{}
- I'm doing that without the @ just to make each comment technically unique and because it seems kinda weird and fun. I notice that some of the script failures happen when commenting on users that have a period in their Instagram username, though not always - sometimes it works with a username with a period. Let me try the same setup without the username{}
to try to isolate the issue.THANKS!