Bounding box and time parameter difficulties in tweepy module python for ArcMap

المشرف العام

Administrator
طاقم الإدارة
I am using a code to develop a map that would show geolocated tweets. The script is as follows:

import tweepy from tweepy import OAuthHandler consumer_key='' consumer_secret='' access_token='' access_token_secret='' auth=tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api=tweepy.API(auth,parser=tweepy.parsers.JSONParser()) tweets=api.search(q='Hillary',geocode='39.0959629363055,-106.5673828125,4751.400mi',count="100") row={} import csv,sys filename='twitter.csv' csvfile= open(filename,'w') csvfile.truncate() fieldnames=["Lat","Tweet","User_Name","Screen_Name","Long"] row={} import csv,sys filename='twitter.csv' csvfile= open(filename,'w') csvfile.truncate() fieldnames=["Lat","Tweet","User_Name","Screen_Name","Long"] writer=csv.DictWriter(csvfile,fieldnames=fieldnames) writer.writeheader() for result in tweets["statuses"]: if result["geo"]: if result["entities"]["user_mentions"]: for r in result["entities"]["user_mentions"]: row["User_Name"]=r["name"] row["Screen_Name"]=r["screen_name"] else: row["Screen_Name"]="" row["User_Name"]="" row["Tweet"]=result["text"] row["Tweet"] = row["Tweet"].encode('ascii', 'replace') row["Lat"]=result["geo"]["coordinates"][0] row["Long"]=result["geo"]["coordinates"][1] writer.writerow(row) csvfile.close() I have a few difficulties in gettinf exactly what I need. 1. For the example above, I have used the keyword as 'Hillary'. If I change it to "HillaryClinton" or ['Hillary','Clinton'], the results give me about 5 to 10 tweets. 2. The geocode parameter gives me results from outside my bounding box as well. 3. How do I modify the script to include a time/day parameter to get the tweets from. 4. What is the maximum count I can assign?

Thank You



أكثر...
 
أعلى