Created
November 11, 2014 01:44
-
-
Save ibaaj/a64733c09c43104ea1d0 to your computer and use it in GitHub Desktop.
Twitter block a list of user with TwitterAPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs | |
from datetime import datetime | |
import sys | |
from TwitterAPI import TwitterAPI, TwitterOAuth, TwitterRestPager | |
###Supposed you have a large list of username like this in a txt file (here: o.txt) : | |
###@aaaa | |
###@bbbb | |
###@cccc | |
###.... | |
### | |
try: | |
# python 3 | |
sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer) | |
except: | |
# python 2 | |
sys.stdout = codecs.getwriter('utf8')(sys.stdout) | |
api = TwitterAPI(consumer_key='',consumer_secret='', access_token_key='',access_token_secret='') | |
lines = [line.strip() for line in open('o.txt')] | |
for user in lines: | |
r = api.request('blocks/create', {'screen_name': user[1:], 'skip_status': '1'}) | |
print(str(r.status_code) + ' ' + user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment