Github: https://github.com/timgrossmann/InstaPy
InstaPy
Instagramの “農業”のための自動化スクリプト、コメント、追従者
Seleniumモジュールを使用してPythonで実装されています。
このツールはサポートする価値があると思いますか? どのように手助けができるかを知るには、 https://github.com/timgrossmann/InstaPy/wiki/How-to-Contributeにお越しください 。 InstaPyの一員になろう!
問題がありますか? これを報告して助けを得る方法については、 https://github.com/timgrossmann/InstaPy/wiki/Reporting-An-Issueにアクセスしてください 。
免責事項 :これは研究プロジェクトであることにご注意ください。 私は決してこのツールの使用に責任を負いません。 あなた自身のために使用してください。 このツールを大量に使用したためにあなたのアカウントが禁止された場合、私はまた責任を負いません。
ニュースレター:ニュースレターのサインアップはこちら!
ソーシャル
スラックワークスペース | InstaPy Twitter | 私のTwitter | 仕組み(中) | 話をチェックしよう |
“Talk Python to me”を聞く – エピソード | サポートInstaPy!
目次
- 入門
- InstaPy利用可能な機能
- コメント
- 以下
- リストに続いて
- 他の人のフォロワーをフォローする
- 他のユーザーがフォローしているユーザーのフォロー
- 他の誰かのフォロワーに従う/フォローする
- 特定のユーザーとの交流
- 他のユーザーがフォローしているユーザーと交流する
- 他人のフォロワーと交流する
- アンフォロー
- アクティブなユーザーをアンフォローしない
- ユーザーのフォロワー数に基づく相互作用
- 場所別コメント
- 場所のような
- タグのような
- フィードのような
- 好きなものを制限する
- ユーザーを無視する
- 制限を無視する
- 友人を除く
- ブラックリストキャンペーン
- スマートハッシュタグ
- フォロー/アンフォロー/除外が機能しない?
- 疑わしいログイン試行を回避する
- サードパーティ製Windows用GUI
- プロキシを使用する
- Firefoxへの切り替え
- 絵文字のサポート
- Clarifai ImageAPI
- サーバーで実行する
- ヘッドレスブラウザで実行する
- 複数のアカウントの実行
- Dockerマイクロサービスマニュアルで実行する
- Dockerでオールインワンを実行する(廃止)
- InstaPyの自動化
- その他の情報
入門
ビデオチュートリアル:
Digital OceanでInstaPyをセットアップする(Debian用)
ガイド:
基本的なインストール:
1. git clone https://github.com/timgrossmann/InstaPy.git
2. cd InstaPy
3. pip install .
or
3. python setup.py install
- ここからあなたのシステム用の
chromedriver
をダウンロードしてください。 .zipファイルを展開して/assets
フォルダーに入れます。
推奨インストール:
InstaPyをインストールする最善の方法は、virtualenvを作成し、そこにInstaPyをインストールして別のファイルから実行することです。
1. virtualenv venv
2. source venv/bin/activate
3. pip install git+https://github.com/timgrossmann/InstaPy.git
あなたがvirtualenvに精通していないなら、 ここでそれについて読んで、あなたの利点にそれを使用してください。 本質的に、これはrootとしてインストールする必要がある唯一の Pythonライブラリです(例えば、sudoで)。 他のすべてのPythonライブラリはvirtualenv内にあるはずです。 次に、以下のquickstart.py
Pythonコードをコピー/ペーストし、最初のInstaPyスクリプトを実行します。 virtualenvからPythonで実行することを忘れないでください。したがって、 venv/bin/python
から実行してください。 どのPythonが使用されているかを確認するには、どのPythonを実行するwhich python
、どのPythonが ‘アクティブ’であるかを教えてください。 source venv/bin/activate
を実行すると、InstaPyを実行するための正しいPythonが有効になります。 起動されたvirtualenvを終了するには `deactivate ‘を実行します。
この基本設定で自分で設定する
基本的なセットアップは、ツールをテストするための良い方法です。 プロジェクトのルートフォルダにquickstart.py
を開き、ユーザ名とパスワードで更新します。
from instapy import InstaPy
insta_username = ''
insta_password = ''
# if you want to run this script on a server,
# simply add nogui=True to the InstaPy() constructor
session = InstaPy(username=insta_username, password=insta_password)
session.login()
# set up all the settings
session.set_upper_follower_count(limit=2500)
session.set_do_comment(True, percentage=10)
session.set_comments(['aMEIzing!', 'So much fun!!', 'Nicey!'])
session.set_dont_include(['friend1', 'friend2', 'friend3'])
session.set_dont_like(['pizza', 'girl'])
# do the actual liking
session.like_by_tags(['natgeo', 'world'], amount=100)
# end the bot session
session.end()
それを実行する:
$ python quickstart.py
または、私たちのGUIの1つを使用してください
InstaPy利用可能な機能
コメント
# default enabled=False, ~ every 4th image will be commented on
session.set_do_comment(enabled=True, percentage=25)
session.set_comments(['Awesome', 'Really Cool', 'I like your stuff'])
# you can also set comments for specific media types (Photo / Video)
session.set_comments(['Nice shot!'], media='Photo')
session.set_comments(['Great Video!'], media='Video')
# and you can add the username of the poster to the comment by using
session.set_comments(['Nice shot! @{}'], media='Photo')
以下
# default enabled=False, follows ~ 10% of the users from the images, times=1
# (only follows a user once (if unfollowed again))
session.set_do_follow(enabled=True, percentage=10, times=2)
リストに続いて
# follows each account from a list of instagram nicknames (only follows a user
# once (if unfollowed again)) would be useful for the precise targeting.
# For example, if one needs to get followbacks from followers of a chosen
# account/group of accounts.
accs = ['therock','natgeo']
session.follow_by_list(accs, times=1)
他の人のフォロワーをフォローする
# Follows the followers of each given user
# The usernames can be either a list or a string
# The amount is for each account, in this case 30 users will be followed
# If randomize is false it will pick in a top-down fashion
session.follow_user_followers(['friend1', 'friend2', 'friend3'], amount=10, randomize=False)
# default sleep_delay=600 (10min) for every 10 user following, in this case
# sleep for 60 seconds
session.follow_user_followers(['friend1', 'friend2', 'friend3'], amount=10, randomize=False, sleep_delay=60)
他のユーザーがフォローしているユーザーのフォロー
# Follows the people that a given users are following
# The usernames can be either a list or a string
# The amount is for each account, in this case 30 users will be followed
# If randomize is false it will pick in a top-down fashion
session.follow_user_following(['friend1', 'friend2', 'friend3'], amount=10, randomize=False)
# default sleep_delay=600 (10min) for every 10 user following, in this case
# sleep for 60 seconds
session.follow_user_following(['friend1', 'friend2', 'friend3'], amount=10, randomize=False, sleep_delay=60)
他の誰かのフォロワーに従う/フォローする
# For 50% of the 30 newly followed, move to their profile
# and randomly choose 5 pictures to be liked.
# Take into account the other set options like the comment rate
# and the filtering for inappropriate words or users
session.set_user_interact(amount=5, randomize=True, percentage=50, media='Photo')
session.follow_user_followers(['friend1', 'friend2', 'friend3'], amount=10, randomize=False, interact=True)
タグでフォロー
# Follow user based on hashtags (without liking the image)
session.follow_by_tags(['tag1', 'tag2'], amount=10)
特定のユーザーとの交流
# Interact with specific users
# set_do_like, set_do_comment, set_do_follow are applicable
session.set_do_follow(enabled=False, percentage=50)
session.set_comments(["Cool", "Super!"])
session.set_do_comment(enabled=True, percentage=80)
session.set_do_like(True, percentage=70)
session.interact_by_users(['user1', 'user2', 'user3'], amount=5, randomize=True, media='Photo')
他のユーザーがフォローしているユーザーと交流する
# Interact with the people that a given user is following
# set_do_comment, set_do_follow and set_do_like are applicable
session.set_user_interact(amount=5, randomize=True, percentage=50, media='Photo')
session.set_do_follow(enabled=False, percentage=70)
session.set_do_like(enabled=False, percentage=70)
session.set_comments(["Cool", "Super!"])
session.set_do_comment(enabled=True, percentage=80)
session.interact_user_following(['natgeo'], amount=10, randomize=True)
他人のフォロワーと交流する
# Interact with the people that a given user is following
# set_do_comment, set_do_follow and set_do_like are applicable
session.set_user_interact(amount=5, randomize=True, percentage=50, media='Photo')
session.set_do_follow(enabled=False, percentage=70)
session.set_do_like(enabled=False, percentage=70)
session.set_comments(["Cool", "Super!"])
session.set_do_comment(enabled=True, percentage=80)
session.interact_user_followers(['natgeo'], amount=10, randomize=True)
アンフォロー
# unfollows 10 of the accounts you're following -> instagram will only
# unfollow 10 before you'll be 'blocked for 10 minutes' (if you enter a
# higher number than 10 it will unfollow 10, then wait 10 minutes and will
# continue then).
# You can choose to only unfollow the user that Insta has followed by adding
# onlyInstapyFollowed = True otherwise it will unfollow all users
# You can choose unfollow method as FIFO (First-Input-First-Output) or
# LIFO (Last-Input-First-Output). The default is FIFO method.
# onlyInstapyMethod is using only when onlyInstapyFollowed = True
# sleep_delay sets the time it will sleep every 10 profile unfollow, default
# is 10min
session.unfollow_users(amount=10, onlyInstapyFollowed = True, onlyInstapyMethod = 'FIFO', sleep_delay=60 )
# You can only unfollow user that won't follow you back by adding
# onlyNotFollowMe = True it still only support on profile following
# you should disable onlyInstapyFollowed when use this
session.unfollow_users(amount=10, onlyNotFollowMe=True, sleep_delay=60)
# You can also unfollow users only after following them certain amount of time,
# this will provide seamless unfollow activity without the notice of the targeted user
# To use, just add `unfollow_after` argument with the desired time, e.g.
session.unfollow_users(amount=10, onlyInstapyFollowed = True, onlyInstapyMethod = 'FIFO', sleep_delay=600, unfollow_after=48*60*60)
# will unfollow users only after following them 48 hours (2 days), since `unfollow_after`s value
# is seconds, you can simply give it `unfollow_after=100` to unfollow after 100 seconds,
# but `1*60*60` (which is equal to 1 hour or 3600 seconds) style is a lot simpler to use 👍
アクティブなユーザーをアンフォローしない
# Prevents unfollow followers who have liked one of your latest 5 posts
session.set_dont_unfollow_active_users(enabled=True, posts=5)
ユーザーのフォロワー数に基づく相互作用
# This is used to check the number of followers a user has and if this number
# exceeds the number set then no further interaction happens
session.set_upper_follower_count(limit = 250)
# This is used to check the number of followers a user has and if this number
# does not pass the number set then no further interaction happens
session.set_lower_follower_count(limit = 1)
場所別コメント
session.comment_by_locations(['224442573/salton-sea/'], amount=100)
# or
session.comment_by_locations(['224442573'], amount=100)
# or include media entities from top posts section
session.comment_by_locations(['224442573'], amount=5, skip_top_posts=False)
このメソッドは、投稿を好きにせずに、場所ごとにコメントすることができます。 場所を取得するには、「場所のように」の指示に従います。
場所のような
session.like_by_locations(['224442573/salton-sea/'], amount=100)
# or
session.like_by_locations(['224442573'], amount=100)
# or include media entities from top posts section
session.like_by_locations(['224442573'], amount=5, skip_top_posts=False)
like_by_locations
関数の場所は、 like_by_locations
ようにして見つけることができます。
- ブラウジングhttps://www.instagram.com/explore/locations/
- 通常の譜表検索。
例:
- ‘Salton Sea’を検索し、位置アイコンで結果を選択してください
- URLはhttps://www.instagram.com/explore/locations/224442573/salton-sea/です。
- 「場所/」またはすべての番号の後にすべてを使用する
タグのような
# Like posts based on hashtags
session.like_by_tags(['natgeo', 'world'], amount=10)
タグのようにしてユーザーと対話する
# Like posts based on hashtags and like 3 posts of its poster
session.set_user_interact(amount=3, randomize=True, percentage=100, media='Photo')
session.like_by_tags(['natgeo', 'world'], amount=10, interact=True)
フィードのような
# This is used to perform likes on your own feeds
# amount=100 specifies how many total likes you want to perform
# randomize=True randomly skips posts to be liked on your feed
# unfollow=True unfollows the author of a post which was considered
# inappropriate interact=True visits the author's profile page of a
# certain post and likes a given number of his pictures, then returns to feed
session.like_by_feed(amount=100, randomize=True, unfollow=True, interact=True)
ブラックリストキャンペーン
# Controls your interactions by campaigns.
# ex. this week InstaPy will like and comment interacting by campaign called
# 'soccer', next time InstaPy runs, it will not interact again with users in
# blacklist
# In general, this means that once we turn off the soccer_campaign again, InstaPy
# will have no track of the people it interacted with about soccer.
# This will help you target people only once but several times for different campaigns
session.set_blacklist(enabled=True, campaign='soccer_campaign')
session.set_do_comment(True, percentage=50)
session.set_comments(['Neymar is better than CR7', 'Soccer is cool'])
session.like_by_tags(['soccer', 'cr7', 'neymar'], amount=100, media='Photo')
スマートハッシュタグ
# Generate smart hashtags based on https://displaypurposes.com ranking,
# banned and spammy tags are filtered out.
# (limit) defines amount limit of generated hashtags by hashtag
# (sort) sort generated hashtag list 'top' and 'random' are available
# (log_tags) shows generated hashtags before use it
# (use_smart_hashtags) activates like_by_tag to use smart hashtags
session.set_smart_hashtags(['cycling', 'roadbike'], limit=3, sort='top', log_tags=True)
session.like_by_tags(amount=10, use_smart_hashtags=True)
好きなものを制限する
session.set_dont_like(['#exactmatch', '[startswith', ']endswith', 'broadmatch'])
.set_dont_like
は、ハッシュタグの説明と所有者のコメントを検索し、ハッシュタグの1 .set_dont_like
場合、画像が気に入らない
InstaPyセッションから投稿を除外する4つのオプションがあります:
-
#
始まる単語は正確なハッシュタグにのみマッチします(例えば、#
#cat
マッチし#cat
、#
#cat
マッチしませ#catpic
) - あなたの単語で始まる全てのハッシュタグにマッチします(例えば
[cat
matches#catpic
、#caturday
など) -
]
始まる単語は、あなたの単語で終わるすべてのハッシュタグにマッチします(例えば、]cat
#mycat
、#instacat
などにマッチします) - これらの接頭辞が付いていない単語は、ハッシュタグの先頭、途中、または末尾に配置されているかどうかにかかわらず、単語を含むすべてのハッシュタグに一致します(たとえば
cat
は#cat
、#mycat
、#caturday
、#rainingcatsanddogs
などと一致します)
ユーザーを無視する
# completely ignore liking images from certain users
session.set_ignore_users(['random_user', 'another_username'])
制限を無視する
# will ignore the don't like if the description contains
# one of the given words
session.set_ignore_if_contains(['glutenfree', 'french', 'tasty'])
友人を除く
# will prevent commenting on and unfollowing your good friends (the images will
# still be liked)
session.set_dont_include(['friend1', 'friend2', 'friend3'])
フォロー/アンフォロー/除外が機能しない?
上記の機能の1つまたは複数が期待どおりに機能していないことに気付いた場合、
session.set_do_follow(enabled=True, percentage=10, times=2)
プロファイルのいずれも追跡されていないか、またはそのような機能が正しく動作していない場合は、スクリプト内のそのようなメソッドの位置/順序を確認する必要があります。 本質的に、すべてのset_*
メソッドは、 like_by_tags
またはlike_by_locations
より前か、またはunfollow
なければなりません。 これはすべてのexmplesとquickstart.pyでも暗黙のうちに
疑わしいログイン試行を回避する
「異常なログイン試行を検出しました」というメッセージに問題がある場合は、この方法でInstaPyを設定することを回避できます。
session = InstaPy(username=insta_username, password=insta_password, bypass_suspicious_attempt=True)
bypass_suspicious_attempt=True
すると、電子メールに確認コードが送信され、電子メールに送信されたセキュリティコードを入力するよう求められます。 あなたのアカウントにログインすると、bypass_suspicious_attemptをFalseに設定できるようになりましたbypass_suspicious_attempt=False
とInstaPyはクッキーを使用してすばやくログインします。
プロキシを使用する
プロキシの背後でInstaPyを使用するには、サーバのアドレスとポートを指定します
session = InstaPy(username=insta_username, password=insta_password, proxy_address='8.8.8.8', proxy_port=8080)
認証でプロキシを使用するには、最初にプロキシクロム拡張を生成する必要があります(Chromeとheadless_browser = Falseでのみ動作します)。
from proxy_extension import create_proxy_extension
proxy = 'login:password@ip:port'
proxy_chrome_extension = create_proxy_extension(proxy)
session = InstaPy(username=insta_username, password=insta_password, proxy_chrome_extension=proxy_chrome_extension, nogui=True)
Firefoxへの切り替え
Chromeはデフォルトのブラウザですが、InstaPyではFirefoxもサポートしています。
session = InstaPy(username=insta_username, password=insta_password, use_firefox=True)
絵文字のサポート
絵文字を使用するには、オープニングアポストロフィの前にu
を追加します。
session.set_comments([u'This post is 🔥',u'More emojis are always better 💯',u'I love your posts 😍😍😍']);
# or
session.set_comments([u'Emoji text codes are also supported :100: :thumbsup: :thumbs_up: \u2764 💯💯']);
絵文字のテキストコードは、2つの異なる命名コードを使用して実装されています。 emojisコードの完全なリストはPython Emoji Githubにありますが、 ここでEmojiテキストコードの代替ショートネーミングスキームを使用することができます 。 注:絵文字はすべてテストされていません。 矛盾があれば報告してください。
従来の絵文字のサポート
コメントにUnicode文字列を使用することはできますが、いくつかの制限があります。
4文字以下のUnicode文字のみを使用でき、Unicodeコード(例:
\u1234
)を使用する必要があります。 ウィキペディアには 、ユニコードコード付きの絵文字のリストがありますが、実際の絵文字/assets
リストもありますコメントをUnicodeに変換する必要があります。 これは、開始アポストロフィの前にuを追加することで安全に実行できます
u'\u1234 some comment'
Clarifai ImageAPI
注: https ://developer.clarifai.com/signup/にアクセスして無料アカウントを作成し、ログインしたらhttps://developer.clarifai.com/account/applications/に移動して新しいアプリケーションを作成します。 そこにクライアントIDとシークレットがあります。 あなたは無料で/月に5000のAPIコールを取得します。
環境に合わせてスクリプトでCLARIFAI_API_KEYを取得するには、次のようにします。
export CLARIFAI_API_KEY="<API KEY>"
Imagecontentの処理の例
session.set_do_comment(True, percentage=10)
session.set_comments(['Cool!', 'Awesome!', 'Nice!'])
session.set_use_clarifai(enabled=True)
session.clarifai_check_img_for(['nsfw'])
session.clarifai_check_img_for(['food', 'lunch', 'dinner'], comment=True, comments=['Tasty!', 'Nice!', 'Yum!'])
session.end()
Imagecheckingの有効化
# default enabled=False , enables the checking with the clarifai api (image
# tagging) if secret and proj_id are not set, it will get the environment
# variables 'CLARIFAI_API_KEY'
session.set_use_clarifai(enabled=True, api_key='xxx')
不適切な画像をフィルタリングする
# uses the clarifai api to check if the image contains nsfw content
# -> won't comment if image is nsfw
session.clarifai_check_img_for(['nsfw'])
特定の内容の画像に対する特化されたコメント
# checks the image for keywords food and lunch, if both are found,
# comments with the given comments. If full_match is False (default), it only
# requires a single tag to match Clarifai results.
session.clarifai_check_img_for(['food', 'lunch'], comment=True, comments=['Tasty!', 'Yum!'], full_match=True)
いくつかの利用可能なタグを見るにはhttps://clarifai.com/demoをチェックしてください 。
サーバーで実行する
nogui
パラメータを使用して仮想ディスプレイと対話する
session = InstaPy(username='test', password='test', nogui=True)
ヘッドレスブラウザで実行する
注: Chromeのみ! ユーザーchromedriver v2.9 +
headless_browser
パラメータを使用して、CLI経由でボットを実行します。 スクリプトをローカルで実行する場合や、サーバーにデプロイする場合に効果的です。 GUIはなく、CPU集約度は低いです。 例
session = InstaPy(username='test', password='test', headless_browser=True)
複数のアカウントの実行
複数のアカウントを使用し、アカウントごとにログファイルを保存する場合は、multi_logsパラメータを使用します。
session = InstaPy(username='test', password='test', multi_logs=True)
Dockerマイクロサービスマニュアルで実行する
Dockerを使用すると、痛みや涙がなくても、instapyボットを非常に簡単かつ迅速に実行できます。
0.準備
公式サイトhttps://www.docker.com/からドッカーをインストールしてください
あなたが持っていない場合は、VNCビューアをインストールしてください。 Windowsの場合、良いプログラムはhttp://www.tightvnc.com/です
1.あなたのInstagramログインとパスワードを設定します
docker_quickstart.py
を開き、insta_usernameとinsta_passwordの後に引用符を入力します。
あなたが望むようにファイルのための他の変更をすることを忘れないでください。 infoについては上記のドキュメントをお読みください。
2. docker-composeでコンテナを実行してビルドする
まず、ターミナルを開き、instapyプロジェクトのルートフォルダ(通常はcd
コマンド)に移動し、次のように入力する必要があります。
docker-compose up -d --build
それで全部です! このステップでは、既にあなたのパーソナルボットを正常に実行しています!
3.今あなたのボットができることを見る
VNCビューアを実行し、アドレスとポートlocalhost:5900
と入力します。 パスワードはsecret
です。
4.あなたのinstapy botを停止する
端末をもう一度使用して、同じウィンドウで入力してください:
docker-compose down
あなたのボットは停止しています!
5.さらなるステップ
これらは、ドッカーでPCにinstapy botを実行するための基本的な手順です。 プロジェクトのルートには他のドッカー作成用設定ファイルがあります。
SSHで実行、テスト、デバッグするための開発環境
それを使って、開発とテストのための手助けをしてください! docker-dev.yml
ファイル。
docker-compose -f docker-dev.yml up -d
このコマンドを実行した後は、 localhost:5901
というアドレスのVNCでボットにアクセスできます。パスワードはsecret
です。
しかし、もっとあります! 完全にアクセス可能なbashコンソールがあり、パス/code
すべてのコードがマウントされてい/code
。 いくつかのファイルをハックすると、それらはコンテナ内で動的に更新されます。
yorコンテナコンソールにアクセスして、好きなsshクライアントでlocalhost:22
を実行します。 ユーザーはroot
で、パスワードもroot
です。
VNCポートを開かずに本番環境で実行
リモートサーバーで実行するのに適しています。 注意! この設定docker-prod.yml
ファイルでVNCを通して起こったことを見ることはできません。
docker-compose -f docker-prod.yml up -d
Dockerでオールインワンを実行する(廃止)
1.イメージを構築する
まず、ターミナルでこれを実行してイメージをビルドする必要があります:
docker build -t instapy ./docker_conf/all_in_one
nogui
機能を使用するようにしてください。
# you can use the nogui parameter to use a virtual display
session = InstaPy(username='test', password='test', nogui=True)
2.コンテナで実行する
ビルドが成功した後は、次の方法でコンテナを実行するだけです。
docker run --name=instapy -e INSTA_USER=<your-user> -e INSTA_PW=<your-pw> -d --rm instapy
InstaPyの自動化
Windowsタスクスケジューラ
タスクスケジューラで構築されたウィンドウを使用して、時間、ログイン、コンピュータアイドルなどのさまざまな種類のトリガを使用してInstaPyを自動化することができます。Instapyスクリプトの簡単な1日の実行をスケジュールするには、
- Windowsタスクスケジューラを開く
- [基本タスクの作成]を選択します。
- 必要に応じて「名前」と「説明」を入力し、「次へ」をクリックします。
- [トリガー]画面で、実行頻度を選択し、[次へ]をクリックします(頻度は後で変更できます)
- 「毎日」画面で「次へ」を押すと、
- “Action Screen”を選択して “Start a program”を選択し、 “Next”をクリックします。
- “Program / script”はパスを入力するか、Pythonへのパスを選択するためにブラウズします。 ( Windows上でpythonパスを見つける方法 )
- “Add arguments”を実行するInstaPyスクリプトパスを入力します。 (例:C:\ Users \ USER_NAME \ Documents \ GitHub \ InstaPy \ craigquick.py)
- Instapyのインストール先(例:C:\ Users \ USER_NAME \ Documents \ GitHub \ InstaPy)を入力します。 [次へ]をクリックします。
- プロセスを終了するには、「完了」をクリックします。
cron
InstaPyをcrontabに追加すると、スクリプトが定期的に実行されます。 これはサーバには特に便利ですが、Instagramsを壊したり、限界に似たりしないように注意してください。
# Edit or create a crontab
crontab -e
# Add information to execute your InstaPy regularly.
# With cd you navigate to your InstaPy folder, with the part after &&
# you execute your quickstart.py with python. Make sure that those paths match
# your environment.
45 */4 * * * cd /home/user/InstaPy && /usr/bin/python ./quickstart.py
スケジュール
スケジュールは、構成にBuilderパターンを使用する定期ジョブのインプロセススケジューラです。 スケジュールを使用すると、シンプルで人間工学的な構文を使用して、Python関数を所定の間隔で定期的に実行できます。
pip install schedule
from instapy import InstaPy
import schedule
import time
def job():
try:
session = InstaPy(selenium_local_session=False) # Assuming running in Compose
session.set_selenium_remote_session(selenium_url='http://selenium:4444/wd/hub')
session.login()
session.set_do_comment(enabled=True, percentage=20)
session.set_comments(['Well done!'])
session.set_do_follow(enabled=True, percentage=5, times=2)
session.like_by_tags(['love'], amount=100, media='Photo')
session.end()
except:
import traceback
print(traceback.format_exc())
schedule.every().day.at("6:35").do(job)
schedule.every().day.at("16:22").do(job)
while True:
schedule.run_pending()
time.sleep(1)
その他の情報
どのように禁止されていない?
内蔵の遅延により、アカウントが禁止されるのを防ぐことができます。 (ちょうど1000ポスト/日が好きではないことを確認してください)
Chromeブラウザ
現在のバージョンのChromeブラウザでは、64ビットシステムが必要です。