def test_tidy(): """We remove things from tweets in history.""" assert ( tools.tidy( u'.@whoever Every (roadtrip) \r\nneeds ©\tsomeone \xa9 "for" corners :-) #blah # tag cc @whoever2 http://t.co/blah :P' ) == "Every roadtrip needs someone for corners tag cc :P" )
import tools if __name__ == '__main__': # Connect. api = twitter.Api( os.environ['CONSUMER_KEY'], os.environ['CONSUMER_SECRET'], os.environ['ACCESS_TOKEN'], os.environ['ACCESS_TOKEN_SECRET'], cache=None, ) history = [] with open('hitchhikers.txt', 'rb') as hitchf: for line in hitchf: history.append(tools.tidy(line)) max_id = None while True: page = api.GetUserTimeline(screen_name=os.environ['SOURCE_ACCOUNT'], max_id=max_id, count=200, include_rts=False, trim_user=True, exclude_replies=True) # Filter out some inline RT's page = filter(lambda tweet: 'RT' not in tweet.text, page) # Indicates no more history if len(page) == 0:
if __name__ == '__main__': # Connect. api = twitter.Api( os.environ['CONSUMER_KEY'], os.environ['CONSUMER_SECRET'], os.environ['ACCESS_TOKEN'], os.environ['ACCESS_TOKEN_SECRET'], cache=None, ) history = [] with open('hitchhikers.txt', 'rb') as hitchf: for line in hitchf: history.append(tools.tidy(line)) max_id = None while True: page = api.GetUserTimeline( screen_name=os.environ['SOURCE_ACCOUNT'], max_id=max_id, count=200, include_rts=False, trim_user=True, exclude_replies=True ) # Filter out some inline RT's page = filter(lambda tweet: 'RT' not in tweet.text, page) # Indicates no more history if len(page) == 0: break