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

Get_tweets gives the same page #101

Closed
AnnOlChik opened this issue Dec 24, 2019 · 6 comments
Closed

Get_tweets gives the same page #101

AnnOlChik opened this issue Dec 24, 2019 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@AnnOlChik
Copy link

AnnOlChik commented Dec 24, 2019

So, I checked get_tweets function with default pages arg 25 and different hashtags. And as output, I got just 25 same pages of tweets. I did this:

from twitter_scraper import get_tweets
for tweet in get_tweets('#brexit'):
    print(tweet['text'], tweet['time'])

When I define the number of pages, it doesn't really change anything.

@bisguzar
Copy link
Owner

Yes, look like scrolling mechanism not working on hashtag pages.

>>> liste = [] 
... from twitter_scraper import get_tweets 
... for tweet in get_tweets('#mock', 3): 
...     liste.append(tweet['tweetId'])                                                                                                                                                                               

>>> liste.count(liste[0])                                                                                                                                                                                            
3 # first tweet's id repeats 3 times in our scraped tweets


>>> liste = [] 
... from twitter_scraper import get_tweets 
... for tweet in get_tweets('bugraisguzar', 3): 
...     liste.append(tweet['tweetId'])                                                                                                                                                                               

>>> liste.count(liste[0])                                                                                                                                                                                            
1 # first tweet's id is uniq as it should be

We will work on it, help needed

@bisguzar bisguzar pinned this issue Jan 11, 2020
@bisguzar bisguzar added the help wanted Extra attention is needed label Jan 11, 2020
@seaona
Copy link

seaona commented May 29, 2020

Got the same error. Does it have to do with the way it's queried and the resulting URL? maybe the pagination works different from User profiles to Hashtags?
Any thoughts? would be awesome to make it work!
Ps. by the way, great repo!

@bisguzar
Copy link
Owner

First at all, thanks. Looks like "max_position" parameter not supported for hashtag pages. I couldn't search it yet. Helps are welcome!

@anushkmittal
Copy link

did anyone have any progress? stuck at the same issue :/

@xeliot
Copy link
Contributor

xeliot commented Jun 27, 2020

Finally got it to work! See changes in #150

Brief summary of how I fixed it by modifying tweets.py:

Change r = session.get(url, headers=headers) to r = session.get(url+'&max_position', headers=headers). This allows response json to return min_position parameter which will then be used as the max_position parameter in the next session.get

r_json = r.json()

Change r = session.get(url, params={'max_position': last_tweet}, headers=headers) to r = session.get(url, params={'max_position': r_json['min_position']}, headers=headers).

This gets rid of twitter pages repeating on search query.

@BradKML
Copy link

BradKML commented Apr 27, 2023

Would this pagination method in search applicable to digging all tweets from a user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants