taspinar / twitterscraper

Scrape Twitter for Tweets
MIT License
2.39k stars 579 forks source link

How to get tweets in a city? #262

Closed Ubaid93 closed 4 years ago

Ubaid93 commented 4 years ago

Hi I want to get the tweets in Melbourne .

begin_date = dt.date(2014,1,1) end_date = dt.date(2014,7,5) limit = 100000000 tweets = query_tweets('oz comic con', begindate = begin_date, enddate = end_date, limit = limit) df1 = pd.DataFrame(t.dict for t in tweets) export_csv = df1.to_csv (r'C:\Users\ubaid\oz_comic_con_2014.csv', index = None, header=True)

What should I do to get the tweets only in Melbourne?. Please look at the code above (I am using python)

I am not sure how to use near function

brndnsy commented 4 years ago

Any luck on this?

Ubaid93 commented 4 years ago

nope

brndnsy commented 4 years ago

Ok cheers, I've been using GetOldTweets3 - managed to scrape 50k tweets via geolocation.

Ubaid93 commented 4 years ago

@lethalbeans can you please help me out on how to get them?

brndnsy commented 4 years ago

@lethalbeans can you please help me out on how to get them?

https://github.com/Mottl/GetOldTweets3

It has good documentation, scroll near the bottom. It tells you how to scrape in Python.

Ubaid93 commented 4 years ago

I have tried that but it only gives a very limited amount of tweets. Please share a chunk of code if possible

smuotoe commented 4 years ago

Hi I want to get the tweets in Melbourne .

begin_date = dt.date(2014,1,1) end_date = dt.date(2014,7,5) limit = 100000000 tweets = query_tweets('oz comic con', begindate = begin_date, enddate = end_date, limit = limit) df1 = pd.DataFrame(t.dict for t in tweets) export_csv = df1.to_csv (r'C:\Users\ubaid\oz_comic_con_2014.csv', index = None, header=True)

What should I do to get the tweets only in Melbourne?. Please look at the code above (I am using python)

I am not sure how to use near function

You could include the near operator in your query. e.g. tweets = query_tweets("'oz comic con' near:Melbourne" begindate = begin_date, enddate = end_date, limit = limit)

lapp0 commented 4 years ago

thanks @smuotoe