結論から言うと、インスタの自動化ツール作成は難易度が高かったです( ;∀;)python初心者(勉強して数週間)が独学で実現するにはレベルが高過ぎましたwww
InstaPyとは
まずInstaPyとは何ぞやという方の為に簡単に説明するとInstagramの自動化ツールです。めんどうな、いいねやフォロバなどの処理を自動で実現するPython用ライブラリです。Twitterには公式APIがありますが、Instagramにはそのようなものはありません。なので、サーボパーティーのライブラリーが有志により作成されたみたいですね。
注意事項
自動でいいねやフォローをしたり、同じコメントを繰り返したりする行為はInstagramのコミュニティガイドラインで禁止されている行為です。この為、短期間で大量のいいねを繰り返すと、BAN(アカウント停止)になる可能性があります。
Instapyというライブラリーがあったので
楽して、インスタの自動化ツールが作成できるのでは?
と甘い考えを持ってしまいましたが、世の中そんなに甘くない。
私は、下記のエラーが出て挫折しました。。。
Cannot detect post media type. Skip https://XXXXX

グーグル先生に解決策を伺ったところ、どうやらバグらしいです。
There is a single word bug in the like_util.py file. It has been submitted as a bug and a merge request has been made. So at some point in the future, you can just reinstall InstaPy and it will get fixed.
Github
like_util.pyのファイルを修正すれば直るらしい。
同様の状況でハマっている海外のプログラマーを何人か発見しました。ME、TOO!!
ただ、問題が分かっても、私には修正方法が分からなくて挫折。
like_util.pyが見つからない。
とりあえず、環境とコードをメモって後日対応しよう。
動作環境
Windows10 64bit PowerShell 7.1.3 Python 3.9.5 InstaPy Version: 0.6.13 Firefox 88.0.1 (64 ビット)
下記コマンドを使って、ライブラリをインストール
pip install instapy
作成したコード
from instapy import InstaPy
from instapy import smart_run
<strong>insta_username = '自分のID' #メールアドレス入力すると正常に動作しません!
insta_password = '自分のパスワード'</strong>
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=False)
with smart_run(session):
session.set_quota_supervisor(enabled=True, sleep_after=["likes", "comments", "follows", "server_calls"], sleepyhead=True, stochastic_flow=True, notify_me=True,
peak_likes_hourly=30,
peak_likes_daily=300,
peak_comments_hourly=5,
peak_comments_daily=1,
peak_follows_hourly=3,
peak_follows_daily=15,
peak_unfollows_hourly=5,
peak_unfollows_daily=60,
peak_server_calls_hourly=20,
peak_server_calls_daily=250)
session.set_do_follow(enabled=True, percentage=50, times=2)
session.like_by_tags(['photography', 'photooftheday', 'instagood', 'instagram', 'photo'],
amount=100, interact=True) #いいねを押したい好きなタグを指定できます
session.set_do_comment(True, percentage=50)
<strong> session.set_comments(["Nice!", "Sweet!", "awesome!", "love it!"]) </strong>
Code language: PHP (php)

Pythonを勉強して数週間が経過しました。何となくPythonについて理解出来てきたような感じがします。まだ、1から0を作成することは出来ませんが、Pythonには便利なライブラリーが沢山あるので、あるものを活用してやりたいことを実現していこうと思います。