Pythonで日本語アカウントをランダムにフォロー
AutoFollow.py
#!/usr/lib/python # vim:fileencoding=utf-8 import time import re import urllib2 import twitter class autoFollow: def __init__(self, account, password): self.user_id = "" self.api = twitter.Api(account, password) def getUserId(self): opener = urllib2.build_opener() json = opener.open('http://pcod.no-ip.org/yats/public_timeline?json').read() if json: self.user_id = re.search('"user": "(.*?)"', json).group(1) def main(self,numbers): for n in range(numbers): try: self.getUserId() self.api.CreateFriendship(self.user_id) print self.user_id except urllib2.URLError, e: print e except AttributeError, e: print e time.sleep(180) time.sleep(180) if __name__ == '__main__': account = '' password = '' numbers = # numbers of members you follow obj = autoFollow(account, password) obj.main(numbers)
クラスやインスタンスの使い方がいまいち分かってません。
大人数フォローは規制かかりそうな気がしますね。
Twitter検索を使わせてもらってます
日本語ユーザーのみのpublic_timelineです。初出のユーザーや日本語判定に失敗したユーザーは表示されません。
http://pcod.no-ip.org/yats/public_timeline
?jsonとかパラメータを渡すとそれで返してくれるそうです。