LoginSignup
2
2

More than 3 years have passed since last update.

Python Tweepyを使っていいねを自動化

Last updated at Posted at 2021-01-24

Python Tweepyを使っていいねを自動化

注意事項

いいねには回数制限があります
噂だと以下の回数なのでAPI実行には注意してください

1分間に30回いいね→3日間規制
1時間に200回いいね→1時間規制
1日に400回いいね→24時間規制

2021/01/24 更新
1日に400回以上いいねした場合、3日間制限と表示された
24時間規制じゃないかもしれない
Tweepyのエラーでは以下のようなメッセージが表示された

[{'code': 283, 'message': "This request looks like it might be automated. To protect our users from spam and other malicious activity, we can't complete this action right now. Please try again later."}]

やっちゃいました、ごめんなさいTwitter

いいねの処理

検索のPythonスクリプトはこちらを参照

キーワード検索した結果をループしてTweetIDを指定してcreate_favoriteを実行することでいいねが実行される

api.create_favorite(id=row.tweet_id)

ポイント
継続的にいいねを行う場合は、どのツイートまでいいねしたか管理する必要がある
キーワード検索の最終TweetID(since_id)を取得しておきDB、ファイルなどに保存

since_id = search[0:1]["tweet_id"]

例: BigQueryに保存
スクリーンショット 2021-01-24 2.39.30.png

検索でsince_idを指定することで前回いいねしたツイート以降を検索でき最新Tweetのみいいねをすることができる

tweets = api.search(
    q=q,
    count=count,
    tweet_mode="extended",
    locale="ja",
    lang="ja",
    include_entities=False,
    max_id=str(last_id - 1),
    since_id=str(since_id),
)
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2