Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Twitter block a list of user with TwitterAPI
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
You can’t perform that action at this time.