Python tweepy finds all tweets in the Netherlands

UPDATE TO THE BOTTOM OF THE QUESTION:

I am trying to create a script that generates all geocoded tweets in the Netherlands. I'm far from getting there. While playing with Tweepy, I ran into a strange situation. I found a script online that could search for tweets containing a keyword. I tried to add parameter validation for geocode. I have succeeded and the below script works. However, when I remove the geocode part of the tweepy.Cursos () call, it no longer works. So this script works:

import tweepy
import csv

consumer_key = "???"
consumer_secret = "???"
access_token = "???"
access_token_secret = "???"

auth = tweepy.auth.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

# Open/Create a file to append data
csvFile = open('tweets.csv', 'a')
#Use csv Writer
csvWriter = csv.writer(csvFile)

for tweet in tweepy.Cursor(api.search,q="*",count=100,geocode="5.29126,52.132633,150km").items(100):
    print [tweet.created_at, tweet.text.encode('utf-8'), tweet.user.id, tweet.geo]
    csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8'), tweet.user.id])

      

UPDATE! Thanks for helping me so far. Now I have one more question regarding my goal - to create a script to collect all tweets with anchor in the Netherlands.

The last piece of my code is to return all geocoded tweets in the Netherlands and write them to a CSV file. Unfortunately, it looks like there are tweets in English. Since there is no Dutch in Dutch, and Dutch people read in English as well, I don't want to set the search language. Why is he only looking for tweets in English? I do not know where I am setting this search characteristic.

Oh, I turned around. Silly mistake. The answer to the question!

+3


source to share


1 answer


You can only set the query string to '*'

using a parameter geocode

. Search q='*'

without the specified is geocode

invalid.



+5


source







All Articles