I have developed a Instagram auto like comment python bot

hims.000

Senior Member
Joined
Apr 10, 2020
Messages
1,014
Reaction score
583
I have developed a Instagram auto like comment python bot.

But there is some problem.

The bot stop working when someone limit their comment section.

i need to add script to skip it.



Note - all guide and bot will be available in the members download section.
 
If you want your bot to skip over accounts with a limited comment section, you can add a simple check to your script that checks whether the comment section is limited before attempting to post a comment.
Here's an example of how this might look in your script:

Code:
# Get account details using the Instagram API
account_details = instagram_api.get_account_details(account_id)

# Check if the account is private
if account_details["is_private"]:
  # Skip over this account and move on to the next one
  continue

# If the account is not private, post a comment as usual
instagram_api.post_comment(account_id, comment_text)
 
If you want your bot to skip over accounts with a limited comment section, you can add a simple check to your script that checks whether the comment section is limited before attempting to post a comment.
Here's an example of how this might look in your script:

Code:
# Get account details using the Instagram API
account_details = instagram_api.get_account_details(account_id)

# Check if the account is private
if account_details["is_private"]:
  # Skip over this account and move on to the next one
  continue

# If the account is not private, post a comment as usual
instagram_api.post_comment(account_id, comment_text)
Here is your Ans OP GL.
I also made a bot in past and for BHW but i was not able to complete the bot because of lack of time, the bot was 90% done.
 
You can get similars scripts via github. is there something unique in your bot? I might be interested if you did
I have just fixed some non working bot script to working..
 
can you show me the script?

or just try to add this before your code

Python:
# Import the necessary libraries
import requests
import json

# Set the access token and user ID
access_token = "<your-access-token>"
user_id = "<your-user-id>"

# Set the URL for the request
url = "https://graph.instagram.com/{}/media?fields=id,comments_disabled&access_token={}".format(user_id, access_token)

# Make the request and retrieve the response
response = requests.get(url)
data = json.loads(response.text)

# Iterate over the posts in the response
for post in data["data"]:
  # Check if the comments are disabled for the post
  if post["comments_disabled"]:
    # If the comments are disabled, skip over this post
    continue

  # If the comments are not disabled, you can proceed with liking and commenting on the post
  # Add your code here
 
here the code is


Code:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import random
import time

def sleep_for_period_of_time():
    limit = random.randint(7,10)
    time.sleep(limit)

user = input("Enter your username: ")
pwd = input("Enter your password: ")

def main():
    options = webdriver.ChromeOptions()
    options.add_argument("--lang=en")
    browser = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options)
    browser.get("https://www.instagram.com")
    sleep_for_period_of_time()

    username_input = browser.find_element_by_css_selector("input[name='username']")
    password_input = browser.find_element_by_css_selector("input[name='password']")

    username_input.send_keys(user)
    password_input.send_keys(pwd)
    sleep_for_period_of_time()

    login_button = browser.find_element_by_xpath("//button[@type='submit']")
    login_button.click()
    sleep_for_period_of_time()

    hashtag = input("Enter your hashtag name: ")
    browser.get(f"https://www.instagram.com/explore/tags/{hashtag}")
    sleep_for_period_of_time()

    first_pic = browser.find_element_by_xpath("//div[@class='_aaq8']/div/div/div[1]/div[1]/a")
    first_pic.click()

    num_post = input("How many post you want to like and leave a comment: ")
    cmmt = input("Type your comment: ")
    sleep_for_period_of_time()

    for i in range(int(num_post)):

        # Like a post
        like_post = browser.find_element_by_xpath("//section[@class= '_aamu _ae3_ _ae47 _ae48']/span[1]/button")
        like_post.click()
        print("Liked!")
        sleep_for_period_of_time()

        #Comment on a post
        cmmt_post = browser.find_element_by_xpath("//textarea[@class='x1i0vuye xvbhtw8 x76ihet xwmqs3e x112ta8 xxxdfa6 x5n08af x78zum5 x1iyjqo2 x1qlqyl8 x1d6elog xlk1fp6 x1a2a7pz xexx8yu x4uap5 x18d9i69 xkhd6sd xtt52l0 xnalus7 x1bq4at4 xaqnwrm xs3hnx8']")
        cmmt_post.click()
        cmmt_post = browser.find_element_by_xpath("//textarea[@class='x1i0vuye xvbhtw8 x76ihet xwmqs3e x112ta8 xxxdfa6 x5n08af x78zum5 x1iyjqo2 x1qlqyl8 x1d6elog xlk1fp6 x1a2a7pz xexx8yu x4uap5 x18d9i69 xkhd6sd xtt52l0 xnalus7 x1bq4at4 xaqnwrm xs3hnx8 focus-visible']")
        cmmt_post.send_keys(cmmt)
        cmmt_post.send_keys(Keys.ENTER)
        print("Commented!")
        time.sleep(5)
        
        #Move on to the next Post
        next_post = browser.find_element_by_xpath("//button[@class='_abl-']//*[name()='svg' and @aria-label='Next']")
        next_post.click()
        print("post " + str(i) + " done!")
        print("Next!")
        sleep_for_period_of_time()

    #Quit the Program
    answer = input("The programm finished! Click on 'e' to exit.. ")
    if answer.lower().startswith("e"):
        browser.quit()
        exit()

if __name__ == "__main__":
    main()
 
can you show me the script?

or just try to add this before your code

Python:
# Import the necessary libraries
import requests
import json

# Set the access token and user ID
access_token = "<your-access-token>"
user_id = "<your-user-id>"

# Set the URL for the request
url = "https://graph.instagram.com/{}/media?fields=id,comments_disabled&access_token={}".format(user_id, access_token)

# Make the request and retrieve the response
response = requests.get(url)
data = json.loads(response.text)

# Iterate over the posts in the response
for post in data["data"]:
  # Check if the comments are disabled for the post
  if post["comments_disabled"]:
    # If the comments are disabled, skip over this post
    continue

  # If the comments are not disabled, you can proceed with liking and commenting on the post
  # Add your code here
check i have comment the code.. dont know why it also not working .. it was working yesterday
 
If you want your bot to skip over accounts with a limited comment section, you can add a simple check to your script that checks whether the comment section is limited before attempting to post a comment.
Here's an example of how this might look in your script:

Code:
# Get account details using the Instagram API
account_details = instagram_api.get_account_details(account_id)

# Check if the account is private
if account_details["is_private"]:
  # Skip over this account and move on to the next one
  continue

# If the account is not private, post a comment as usual
instagram_api.post_comment(account_id, comment_text)

Here it is https://www.blackhatworld.com/seo/g...t-with-python-script-with-full-guide.1459888/
 
here the code is


Code:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import random
import time

def sleep_for_period_of_time():
    limit = random.randint(7,10)
    time.sleep(limit)

user = input("Enter your username: ")
pwd = input("Enter your password: ")

def main():
    options = webdriver.ChromeOptions()
    options.add_argument("--lang=en")
    browser = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options)
    browser.get("https://www.instagram.com")
    sleep_for_period_of_time()

    username_input = browser.find_element_by_css_selector("input[name='username']")
    password_input = browser.find_element_by_css_selector("input[name='password']")

    username_input.send_keys(user)
    password_input.send_keys(pwd)
    sleep_for_period_of_time()

    login_button = browser.find_element_by_xpath("//button[@type='submit']")
    login_button.click()
    sleep_for_period_of_time()

    hashtag = input("Enter your hashtag name: ")
    browser.get(f"https://www.instagram.com/explore/tags/{hashtag}")
    sleep_for_period_of_time()

    first_pic = browser.find_element_by_xpath("//div[@class='_aaq8']/div/div/div[1]/div[1]/a")
    first_pic.click()

    num_post = input("How many post you want to like and leave a comment: ")
    cmmt = input("Type your comment: ")
    sleep_for_period_of_time()

    for i in range(int(num_post)):

        # Like a post
        like_post = browser.find_element_by_xpath("//section[@class= '_aamu _ae3_ _ae47 _ae48']/span[1]/button")
        like_post.click()
        print("Liked!")
        sleep_for_period_of_time()

        #Comment on a post
        cmmt_post = browser.find_element_by_xpath("//textarea[@class='x1i0vuye xvbhtw8 x76ihet xwmqs3e x112ta8 xxxdfa6 x5n08af x78zum5 x1iyjqo2 x1qlqyl8 x1d6elog xlk1fp6 x1a2a7pz xexx8yu x4uap5 x18d9i69 xkhd6sd xtt52l0 xnalus7 x1bq4at4 xaqnwrm xs3hnx8']")
        cmmt_post.click()
        cmmt_post = browser.find_element_by_xpath("//textarea[@class='x1i0vuye xvbhtw8 x76ihet xwmqs3e x112ta8 xxxdfa6 x5n08af x78zum5 x1iyjqo2 x1qlqyl8 x1d6elog xlk1fp6 x1a2a7pz xexx8yu x4uap5 x18d9i69 xkhd6sd xtt52l0 xnalus7 x1bq4at4 xaqnwrm xs3hnx8 focus-visible']")
        cmmt_post.send_keys(cmmt)
        cmmt_post.send_keys(Keys.ENTER)
        print("Commented!")
        time.sleep(5)
       
        #Move on to the next Post
        next_post = browser.find_element_by_xpath("//button[@class='_abl-']//*[name()='svg' and @aria-label='Next']")
        next_post.click()
        print("post " + str(i) + " done!")
        print("Next!")
        sleep_for_period_of_time()

    #Quit the Program
    answer = input("The programm finished! Click on 'e' to exit.. ")
    if answer.lower().startswith("e"):
        browser.quit()
        exit()

if __name__ == "__main__":
    main()
This is simple selenium Bot. Note that as it’s Not hiden anyhow, Instagram doesn’t like it. No possibility to make it in such form for more accounts or mass liking/commenting.
 
Its a good time to learn about try and except blocks. Test to see if a particular element is missing or disabled and make the execution conditional to the option being available
 
This is simple selenium Bot. Note that as it’s Not hiden anyhow, Instagram doesn’t like it. No possibility to make it in such form for more accounts or mass liking/commenting.
Yeah just to piggy back off of this… selenium is the worse for automating these days. My suggestion Puppeteer or GoLang, or even better phone automation.
 
Its a good time to learn about try and except blocks. Test to see if a particular element is missing or disabled and make the execution conditional to the option being available
Yep. I’ve done this plenty of times specifically for what Op is encountering. Only thing is try and except slows the bot done tremendously.
 
I feel like the ranking system for instagrams comment section has changed so much over the years. It used to be based off comment likes but idk now.
 
I feel like the ranking system for instagrams comment section has changed so much over the years. It used to be based off comment likes but idk now.
Now somehow randomly it works, formerly in the top immediately raised, but at the moment it is not understandable, but according to statistics and now with the liking more traffic.
 
Back
Top