-
-
Save jpmens/55f35dc13ca2aced972e0518d6910640 to your computer and use it in GitHub Desktop.
Tweepy test: Check for posters with hashtag that follow a certain user and block them
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
# Tweepy API documentation: http://docs.tweepy.org/en/latest/index.html | |
# Vorher mit 'pip install tweepy' Tweepy installieren | |
# Twitter App registrieren unter https://apps.twitter.com/ | |
import tweepy | |
auth = tweepy.OAuthHandler("Consumer Key (API Key)", "Consumer Secret (API Secret)") | |
auth.set_access_token("Access Token", "Access Token Secret") | |
api = tweepy.API(auth) | |
# The user that people follow | |
auser = api.get_user("TwitterHandle") | |
auserid=auser.id | |
# Iterate through 100 posts with a certain hashtag, may hit API throttling eventually (15 minutes wait) | |
for tweet in tweepy.Cursor(api.search, q="#hashtag", count=10, include_entities=True).items(100): | |
userid = tweet.user.id | |
userfollower = tweet.user.followers_count | |
username = tweet.user.name.encode('utf-8', errors = 'ignore') | |
# Does the tweet author follow the user defined above? | |
status = api.show_friendship(source_id=userid, target_id=auserid) | |
# If he does print | |
if status[0].following: | |
print username + " folgt " + auser + "(" + str(userfollower) + "Followers)" | |
# Block the user | |
if api.create_block(id = userid): | |
print " " + username + " blocked successfully" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
unable to import SensoreTagcc2650 as sensortag
help me out please
thanks