0

I'm almost new to python. I'm writing an instagram bot to share posts of my page to people on instagram. But i get restricted most of the times by instagram.

My first question is how to use proxies in instagrapi to bypass the restrictions. And the code below is what instagrapi documentation has put on their github page.

from instagrapi import Client

cl = Client()
before_ip = cl._send_public_request("https://api.ipify.org/")
cl.set_proxy("http://<api_key>:wifi;ca;;;toronto@proxy.soax.com:9137")
after_ip = cl._send_public_request("https://api.ipify.org/")

print(f"Before: {before_ip}")
print(f"After: {after_ip}")

But I actually don't know how to use it. I mean, how should I play with the proxies while the bot is on and working? should i just use once when robot starts, or I have to change proxy after a couple of actions done? (like gathering 10 users from instagram)

And in any of these ways, how should the code look like?

1 Answers1

0

I'm by no means an experienced programmer but maybe this'll help you out. I wouldn't recommend using proxies (first of all they aren't the safest option out there) but in my experience Instagram will flag you anyway and may end up banning your account all together.

Have a look at the dump_settings in the Instagrapi documentation here https://adw0rd.github.io/instagrapi/usage-guide/interactions.html

This way Instagram 'remembers' you and doesn't flag you as much. Or so it seems. I'm still looking for a definitive way to avoid the 429 status. Maybe using the time module. Still looking into it.

Here's my current code if it can help:

import os
from instagrapi import Client

client = Client()
    
if os.path.isfile('C:\Work In Progress\Python Code\IG_bot\dump_settings') == True:
    client.load_settings("C:\Work In Progress\Python Code\IG_bot\dump_settings")
    print("\n\nDump Settings Already Recorded")

else:
    client.dump_settings("C:\Work In Progress\Python Code\IG_bot\dump_settings")
    print("\n\nDump Settings Record Created")

client.login(username,password)
Zciurus
  • 786
  • 4
  • 23
AppleUser
  • 1
  • 1