Пример #1
0
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)

#tweeter.api take arguments like auth_handler, host, search_host,..
api = API(auth)

myfile = open('twetdata.csv', 'a')

try:

    myfile = open('tweetdata.txt', 'a')

    ##########################retweet given tweet##############################
    #Retweets a tweet. Requires the id of the tweet you are retweeting.
    #returns status object

    retweet_this_tweet_id = '860791905831006208'

    retweet_object = api.retweet(retweet_this_tweet_id)

    write_into_file_func("retweet")
    write_into_file_Status(retweet_object)

    print("Successfully implemented retweet function")

    myfile.close()
except Exception as e:

    print("Error Occured. " + str(e) + " Try Again. ")
Пример #2
0
#tweeter.api take arguments like auth_handler, host, search_host,..
api = API(auth)

try:

    myfile = open('tweetdata.txt', 'a')

    ##################------get_user------------##################
    #returns all info of specific user
    #returns User object

    user = "******"
    user_info = api.get_user(user)

    write_into_file_func("get_user")
    write_into_file_User(user, user_info, True)

    print("Successfully implemented get_user")

    ##################------me------------##################

    #returns all info about authenticated user
    #returns User object

    #for json data:
    #	myfile.write("##########Json##########\n")
    #	myfile.write(str(my_info._json))

    my_info = api.me()
Пример #3
0
consumer_key, consumer_secret, access_token, access_secret = get_tokens()

auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)

#tweeter.api take arguments like auth_handler, host, search_host,..
api = API(auth)

try:

    myfile = open('tweetdata.txt', 'a')

    ###############------------trends_available-------#####################
    #returns json object

    print("43")
    trends = api.trends_available()
    print("32432")

    write_into_file_func("trends_avaliabe")

    for i in trends:
        myfile.write(str(i) + "\n\n")

    print("Successfully implement treands_available")

    myfile.close()
except Exception as e:

    print("Error Occured. " + str(e) + " Try Again. ")
Пример #4
0
#tweeter.api take arguments like auth_handler, host, search_host,..
api = API(auth)

try:

    myfile = open('tweetdata.txt', 'a')

    ###############---------search(by Query)-------#####################
    #Returns tweets that match a specified query.
    #returns list of SearchResult object

    query = "michael jackson"

    search_result_general = api.search(q=query, lang="", geocode="")

    write_into_file_func("search(by query general)")

    for i in search_result_general:
        write_into_file_Status(i)

    print("Successfully implemented search by query(general)")

    ###############---------search(by Query Language)-------#####################
    #Returns tweets that match a specified query, lang="resultant language", local="query language"
    #rpp = "maximum return tweet per page into 100"
    #returns list of SearchResult object

    #@@@@@@@@@@@@@@@@@@@@@@@@
    #how to pass more than one lang to search method in tweepy

    query = "ગુજરાતી"
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)

#tweeter.api take arguments like auth_handler, host, search_host,..
api = API(auth)

try:

    myfile = open('tweetdata.txt', 'a')
    ###############---------direct_messages-------#####################
    #Returns direct messages sent to the authenticating user.
    #returns list of direct message object

    direct_messages_of_me = api.direct_messages()

    write_into_file_func("direct_messages")

    for i in direct_messages_of_me:
        write_into_file_DirectMessage(i)

    print("Successfully implemented direct_messages")

    ###############---------sent_direct_messages-------#####################
    #Returns direct messages sent by the authenticating user.
    #returns list of direct message object

    sent_direct_messages_of_me = api.sent_direct_messages()

    write_into_file_func("sent_direct_messages")

    for i in sent_direct_messages_of_me:
Пример #6
0
#tweeter.api take arguments like auth_handler, host, search_host,..
api = API(auth)

try:

    myfile = open('tweetdata.txt', 'a')

    ###############---------followers_ids-------#####################
    #returns id of users which are followed by specific user
    #return type is list of integer

    user = "******"

    all_followers_of_user = api.followers_ids(user)

    write_into_file_func("followers_ids")
    myfile.write("\nName & ID of Followers of " + user + " are : \n")

    for i in all_followers_of_user:
        myfile.write(((api.get_user(i)).name) + "\t\t" + str(i) + "\n")

    print("Successfully implemented followers_ids")

    ###############---------friends_ids-------#####################
    #returns id of followers of specific user
    #return type is list of integer

    user = "******"

    all_followers_of_user = api.friends_ids(user)
Пример #7
0
api = API(auth)

try:

    myfile = open('tweetdata.txt', 'a')

    ###############---------favorites-------#####################
    #Returns the favorite statuses for the authenticating user
    #or user specified by the ID parameter.
    #return list of Status Object

    #800405530401353728
    user = "******"
    user_favorites = api.favorites(user)

    write_into_file_func("favorites")

    myfile.write("\nList of All Favorites of User " + user)

    for i in user_favorites:
        write_into_file_Status(i)

    print("Successfully implemented favorites")

    ###############---------create_favorite-------#####################
    #Favorites the status specified in the ID parameter as the authenticating user.
    #return Status Object

    #code 139 you have already favorite the status
    status_id = "800405530401353728"