print('users found saved to the database: ') for elem in tweets: list_user.append({'user_id': elem.user.id, 'screen_name': elem.user.screen_name, 'description': elem.user.description}) list_hashtag.append({'user_of_hashtag': elem.user.id, 'hashtag_text': query}) list_tweets.append({'user_tweets': elem.user.id, 'tweet_message': elem.text, 'created_date': elem.created_at}) for itemr, itemh, itemt in zip(list_user, list_hashtag, list_tweets): try: #The following is the same as the short version Recruited.create(**itemr) #a= Recruited.create(user_id = itemr['user_id'],screen_name = itemr['screen_name'],description=itemr['description']) a = Recruited.create(**itemr) b = Hashtag.create(**itemh) c = Tweets.create(**itemt) a.save() b.save() c.save() except IntegrityError: pass return list_user t = Tw() t.select_account() db = SqliteDatabase('recruited.db') db.connect() new_recruit = Recruit(t, db) list_recruited = new_recruit.search_and_save_users() print( list(list_recruited) )
send = raw_input('Are you sure you want to send them? Y=yes, N=no: ') if send.lower() == 'y': self.send_tweet(contructed_tweet) else: exit() # confirm send this tweet? # if yes: send_tweet(constructed_message returned from def constructed_message) # if not: cancel else: print("There are no recruiters") exit() def insert_in_database(user, id_tweet, message, date): query_user = SentDate.create(user_sent= user, tweet_sent_message= message, date_tweet_sent= date) query_user.save() t = Tw() twitter, i = t.select_account() db = SqliteDatabase('recruited.db') db.connect() insert_in_database( 44973121, 995, "just python5", datetime.datetime.now() ) new_target = Target(twitter, db, t.get_screen_name() ) new_target.send_tweet_to_recruited() #print( new_target.get_hashtags() )
import pickle from tw import Tw t = Tw() t.select_account() ids, screen_nameBot = t.getFollowers() pickle.dump(ids, open("screen_names_" + screen_nameBot + ".p", "wb"))