Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Accessing enterprise search API #519

Open
tolgaouz opened this issue Jul 15, 2019 · 0 comments
Open

Accessing enterprise search API #519

tolgaouz opened this issue Jul 15, 2019 · 0 comments

Comments

@tolgaouz
Copy link

I want to use enterprise search api for this because I want to define fromDate and toDate parameters.

I couldn't find any way to do it though, and when I try to cursor tweets from this date, It only returns the tweets about 14 days ago from now.

twitter = Twython(consumer_token, access_token=ACCESS_TOKEN)

Search parameters

def search_query(QUERY_TO_BE_SEARCHED):
"""
QUERY_TO_BE_SEARCHED : text you want to search for
"""
df_dict=[]

results = twitter.cursor(twitter.search, q=QUERY_TO_BE_SEARCHED,fromDate='2019071200',toDate='2019071400',count=100)
for q in results:
    retweet_count = q['retweet_count']
    favs_count = q['favorite_count']
    date_created = q['created_at']
    text = q['text']
    hashtags = q['entities']['hashtags']
    user_name = '@'+str(q['user']['screen_name'])
    user_mentions = []
    if(len(q['entities']['user_mentions'])!=0):
        for n in q['entities']['user_mentions']:
            user_mentions.append(n['screen_name']) # Mentioned profile names in the tweet
    temp_dict = {'User ID':user_name,'Date':date_created,'Text':text,'Favorites':favs_count,'RTs':retweet_count,
                'Hashtags':hashtags,'Mentions':user_mentions}
    df_dict.append(temp_dict)

return pd.DataFrame(df_dict)

that is my code, can you help me improve this ?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant