Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

tso.set_count(5) #29

Open
maerco opened this issue Apr 27, 2016 · 3 comments
Open

tso.set_count(5) #29

maerco opened this issue Apr 27, 2016 · 3 comments

Comments

@maerco
Copy link

maerco commented Apr 27, 2016

tso.set_count(5)
is not working on my side:

try:
    tso = TwitterSearchOrder()
    tso.set_keywords(['Lucca'])
    tso.set_count(5)
    tso.set_result_type('recent')
#    tso.set_until(datetime.date(2016, 04, 27))
#    tso.set_until(datetime.date(datetime.now()))


    ts = TwitterSearch(
        consumer_key = 'xxx',
        consumer_secret = 'xxx',
        access_token = 'xxxx,
        access_token_secret = 'xxxx'
     )

    for tweet in ts.search_tweets_iterable(tso):

        print tweet['entities']['media'][0]['media_url_https']

except TwitterSearchException as e: # take care of all those ugly errors if there are some
    print(e)

it's reporting hundred of results.

@ckoepp
Copy link
Owner

ckoepp commented May 4, 2016

Thanks for opening this issue.

As far as I see it, TwitterSearch works as intended here. The count argument does not limit the number of tweets you'll see in your use case. It does limit the number of tweets you'll receive within a single request, though.

In other words: if you're using it within the for-loop you'll only increase the overhead as the lib will simply do more queries to fetch all tweets. If you're sure you'll only need five tweets, you can still set the parameter and leave the for-loop after receiving all tweets you need. By doing so, you'll limit the overhead to a minimum.

Hope this answers the confusion and I guess we should add this point to the documentation as you can get confused easily by the name of the parameter 😄

@maerco
Copy link
Author

maerco commented May 4, 2016

Hi,

Thanks for your replay, yes this clarify the point.

Anyway would be useful to include also a limit for each request, this could save bandwidth if we are performing frequent requests

@ckoepp
Copy link
Owner

ckoepp commented May 10, 2016

There is already a statistical feature available. Just use the getStatistics() method of the TwitterSearch class.

All you need to do is a simple check against the amount of queries. If 5 queries or 1000 tweets are enough for you, just use break within the foreach-loop.

Although we could also implement a kind of limit feature within the TwitterSearch class to automatically break the loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants