x into all the boxes [ ] relevant to your issue (like so [x]).Paste the output of python -V here:
Code:
"""
instabot example
Dependencies:
You must have a file with comments to post.
The file should have one comment per line.
Notes:
You can change file and add there your comments.
"""
import sys
import os
sys.path.append(os.path.join(sys.path[0], '../../'))
from instabot import Bot
if len(sys.argv) < 3:
print("USAGE: Pass a path to the file with comments and a hashtag to comment")
print("Example: %s comments_emoji.txt dog cat" % sys.argv[0])
exit()
comments_file_name = sys.argv[1]
hashtags = sys.argv[2:]
if not os.path.exists(comments_file_name):
print("Can't find '%s' file." % comments_file_name)
exit()
bot = Bot(comments_file=comments_file_name)
bot.login()
for hashtag in hashtags:
bot.comment_hashtag(hashtag)
bot.logout()
Error/Debug Log:
2019-06-23 14:39:18,352 - INFO - Logged-in successfully as 'my_account_name_is here'!
2019-06-23 14:39:18,358 - INFO - Going to comment medias by dog hashtag
2019-06-23 14:39:21,673 - INFO - Going to comment 85 medias.
0%| | 0/85 [00:00<?, ?it/s]
2019-06-23 14:39:22,953 - ERROR - Request returns 405 error!
2019-06-23 14:39:22,953 - ERROR - Error checking for `feedback_required`, response text is not JSON
2019-06-23 14:39:22,954 - INFO - Bot stopped. Worked: 0:06:16.702757
2019-06-23 14:39:22,954 - INFO - Total requests: 12
2019-06-23 14:39:23,144 - ERROR - Request returns 405 error!
2019-06-23 14:39:23,144 - ERROR - Error checking for `feedback_required`, response text is not JSON
2019-06-23 14:39:23,144 - INFO - Bot stopped. Worked: 0:06:16.893303
2019-06-23 14:39:23,144 - INFO - Total requests: 13
I have updated the instabot using "pip install -U instabot" and after that hashtag commenting does not work.
I also tried to clone from Github the latest version, and it has the same problem.
"comments_emoji.txt" file has multiple comments in it.
Can you show me exactly what you type into the terminal when you run this script? Also, did this issue just start happening after you ran pip install -U instabot?
sudo python comment_hashtags.py comments_emoji.txt dog
On 24 Jun 2019, at 06:13, Jon Henshaw notifications@github.com wrote:
Can you show me exactly what you type into the terminal when you run this script?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/instagrambot/instabot/issues/960?email_source=notifications&email_token=AGLTMVFAXDRFG2LXQS7J6N3P4A3U5A5CNFSM4H2YWSM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLUHEA#issuecomment-504841104, or mute the thread https://github.com/notifications/unsubscribe-auth/AGLTMVFZEZWB5FQ7O5BJVGLP4A3U5ANCNFSM4H2YWSMQ.
commenting is doesn't work :(
Can you show me exactly what you type into the terminal when you run this script? Also, did this issue just start happening after you ran
pip install -U instabot?
Yes .. I noticed, that it does not work after I did the "pip install -U instabot".
it seems that if I did that recommended temporary fix for 405 error, then result improved littlebit:
2019-06-25 16:38:02,698 - INFO - Logged-in successfully as 'my_user_name_is_here'!
2019-06-25 16:38:02,704 - INFO - Going to comment medias by dog hashtag
2019-06-25 16:38:05,566 - INFO - Going to comment 84 medias.
0%| | 0/84 [00:00, ?it/s]
Blacklist hashtag found in media, skipping!
2019-06-25 16:38:06,539 - INFO - Bot stopped. Worked: 2 days, 2:05:00.288304
2019-06-25 16:38:06,540 - INFO - Total requests: 20
2019-06-25 16:38:06,541 - INFO - Bot stopped. Worked: 2 days, 2:05:00.289661
2019-06-25 16:38:06,541 - INFO - Total requests: 20
Forementioned fix I did:
"a temporary solution for prevent logout error is to comment the line
self.is_logged_in = not self.send_request('accounts/logout/')
in api.py logout function"
yes, logout is broken atm
also it trying to filter medias and breaks right after first user who doesn't apply internal limits like "likes to like" etc, seems like that checking is an overhead, but at least it shouldn't stop
so
fixes
api.py
def logout(self, *args, **kwargs):
if not self.is_logged_in:
return True
data = json.dumps({})
self.is_logged_in = not self.send_request('accounts/logout/', data, with_signature=False)
return not self.is_logged_in
bot_comment.py
def comment_medias(self, medias):
broken_items = []
self.logger.info("Going to comment %d medias." % (len(medias)))
for media in tqdm(medias):
if not self.check_media(media):
continue
if not self.is_commented(media):
text = self.get_comment()
self.logger.info("Commented with text: %s" % text)
if not self.comment(media, text):
self.delay('comment')
broken_items = medias[medias.index(media):]
break
self.logger.info("DONE: Total commented on %d medias. " %
self.total['comments'])
return broken_items
When I made those changes locally and ran the comment_hashtags.py in my computer it works perfectly.
When doing the exact same thing in GoogleCloud instance, then:
2019-06-28 08:30:17,790 - INFO - Logged-in successfully as 'my_IG_username'!
2019-06-28 08:30:17,791 - INFO - Going to comment medias by dog hashtag
2019-06-28 08:30:20,372 - INFO - Going to comment 84 medias.
0%| | 0/84 [00:00, ?it/s]
2019-06-28 08:30:20,746 - ERROR - Request returns 405 error!
2019-06-28 08:30:20,747 - ERROR - Error checking for feedback_required, response text is not JSON
2019-06-28 08:30:20,747 - INFO - Bot stopped. Worked: 11 days, 1:52:13.745046
2019-06-28 08:30:20,747 - INFO - Total comments: 65/100
2019-06-28 08:30:20,747 - INFO - Total requests: 19167
2019-06-28 08:30:20,805 - ERROR - Request returns 405 error!
2019-06-28 08:30:20,805 - ERROR - Error checking for feedback_required, response text is not JSON
2019-06-28 08:30:20,805 - INFO - Bot stopped. Worked: 11 days, 1:52:13.803495
2019-06-28 08:30:20,805 - INFO - Total comments: 65/100
2019-06-28 08:30:20,806 - INFO - Total requests: 19168
Any ideas?
If it was installed by pip, you need to modify it at python dist-packages (located usually at /usr/lib/python* or /usr/local/lib/python*)
@stas2z do we need to modify /usr/local/lib/python* everytime we use new feature? Because everytime i use a feature for the first time i got error 405!! How to fix it without change every dist-packages in local?
I wrote such a script for commenting, although it is big, but it works!
And he first filters and then comments.
Therefore, he comments on the exact number of desired posts.
import os
import sys
import time
import random
from instabot import Bot, utils
USERNAME = "USERNAME"
PASSWORD = "PASSWORD"
HASHTAGS = ["cat", "dog", "summer", "sea", "selfie"]
AMOUNT_COMMENT_HASHTAG = 288 // 18 # 16 comments
comment_hashtags_delay = 60 * 60 * 2 # per 2 hours
bot = Bot()
bot.login(username=USERNAME, password=PASSWORD)
bot.filter_business_accounts = False
while True:
checked_medias = []
for random_hashtag in HASHTAGS:
random_hashtag = random.choice(HASHTAGS)
bot.logger.info(USERNAME + " is collecting medias by hashtag \"" + random_hashtag + "\" for commenting.")
medias = bot.get_total_hashtag_medias(random_hashtag, AMOUNT_COMMENT_HASHTAG * 10)
for media in medias:
if len(checked_medias) == AMOUNT_COMMENT_HASHTAG:
bot.logger.info(USERNAME + " is commenting hashtag: " + random_hashtag + ".")
bot.comment_medias(checked_medias)
break
else:
checked_media = bot.check_media(media)
if checked_media != False:
checked_medias = checked_medias + [media]
print ("\nTaken " + str(len(checked_medias)) + "/" + str(AMOUNT_COMMENT_HASHTAG) + " medias.")
if len(checked_medias) == AMOUNT_COMMENT_HASHTAG:
break
time.sleep(comment_hashtags_delay)
I wrote such a script for commenting, although it is big, but it works!
And he first filters and then comments.
Therefore, he comments on the exact number of desired posts.import os import sys import time import random from instabot import Bot, utils USERNAME = "USERNAME" PASSWORD = "PASSWORD" HASHTAGS = ["cat", "dog", "summer", "sea", "selfie"] AMOUNT_COMMENT_HASHTAG = 288 // 18 # 16 comments comment_hashtags_delay = 60 * 60 * 2 # per 2 hours bot = Bot() bot.login(username=USERNAME, password=PASSWORD) bot.filter_business_accounts = False while True: checked_medias = [] for random_hashtag in HASHTAGS: random_hashtag = random.choice(HASHTAGS) bot.logger.info(USERNAME + " is collecting medias by hashtag \"" + random_hashtag + "\" for commenting.") medias = bot.get_total_hashtag_medias(random_hashtag, AMOUNT_COMMENT_HASHTAG * 10) for media in medias: if len(checked_medias) == AMOUNT_COMMENT_HASHTAG: bot.logger.info(USERNAME + " is commenting hashtag: " + random_hashtag + ".") bot.comment_medias(checked_medias) break else: checked_media = bot.check_media(media) if checked_media != False: checked_medias = checked_medias + [media] print ("\nTaken " + str(len(checked_medias)) + "/" + str(AMOUNT_COMMENT_HASHTAG) + " medias.") if len(checked_medias) == AMOUNT_COMMENT_HASHTAG: break time.sleep(comment_hashtags_delay)
Bro it comments "Wow", how to change comment in your script?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
If it was installed by pip, you need to modify it at python dist-packages (located usually at /usr/lib/python* or /usr/local/lib/python*)