|
1 |
| -TwitterGeo |
2 |
| -========== |
| 1 | +### UNDER DEVELOPMENT ### |
3 | 2 |
|
4 |
| -Scripts for geocoding tweets and for downloading images embedded in tweets. |
| 3 | +_Expected release date is sometime in early February 2013_ |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +### TwitterGeo ### |
| 8 | + |
| 9 | +_Scripts for geocoding tweets and for downloading images embedded in tweets._ |
| 10 | + |
| 11 | +TwitterGeo contains command line scripts for geocoding tweets and extracting embedded images from tweets from twitter.com. The scripts take one or more search words as command line arguments. The scripts download old tweets using Twitter's REST API and download new tweets using Twitter's Streaming API. |
| 12 | + |
| 13 | +About 1% or 2% of tweets contain latitude and longitude. Of those tweets that do not contain coordinate data, about 60% have the user's profile location, a descriptive text field that may or not be accurate. Using Google's Maps API, we can geocode these tweets, which locates about half of all tweets, a portion of which are suspect. |
| 14 | + |
| 15 | +Use the location option to restrict searches to a geographic location. Twitter returns tweets that either contain geocode in the location region or tweets from users whose profile location is in the specified region. |
| 16 | + |
| 17 | +Google does not require autentication, but it does enforce a daily limit of about 2,500 requests per day and about 10 requests per second. |
| 18 | + |
| 19 | +The Twitter API's require OAuth credentials which you can get by creating an application on dev.twitter.com. Once you have your OAuth secrets and keys, copy them into twittergeo/credentials.txt. Alternatively, specify the credentials file on the command line. |
| 20 | + |
| 21 | +Twitter restricts searching old tweets to within roughly the past week. Twitter also places a bandwidth limit on searching current tweet, but you will notice this only when you are searching a popular word. When this limit occurs the total number of skipped tweets is printed and the connection is maintained. |
| 22 | + |
| 23 | +# Features # |
| 24 | + |
| 25 | +*The following modules run as command line scripts and write tweets to the console.* |
| 26 | + |
| 27 | +### SearchGeo ### |
| 28 | + |
| 29 | +Prints old tweets and their location information and coordinates when possible. |
| 30 | + |
| 31 | +### StreamGeo ### |
| 32 | + |
| 33 | +Prints new tweets and their location information and coordinates when possible. |
| 34 | + |
| 35 | +### SearchPics ### |
| 36 | + |
| 37 | +Prints old tweets, their coordinates and URLs of any embedded photos. To download the photos use the -photo_dir option. To get tweets only from a specific geographic region use the -location. |
| 38 | + |
| 39 | +### StreamPics ### |
| 40 | + |
| 41 | +Prints new tweets, their coordinates and URLs of any embedded photos. To download the photos use the -photo_dir option. To get tweets only from a specific geographic region use the -location. |
| 42 | + |
| 43 | +*These are utility modules.* |
| 44 | + |
| 45 | +### Geocoder ### |
| 46 | + |
| 47 | +A wrapper for pygeocoder that provides a few Twitter helper methods. It adds throttling to respect Google's daily quota and rate limit. It also provides a caching mechanism for storing geocode lookups to a text file. The caching is only partially effective because user can enter their location in any format. |
| 48 | + |
| 49 | +# Installation # |
| 50 | + |
| 51 | + |
| 52 | +1. On a command line, type: |
| 53 | + |
| 54 | +`pip install twittergeo` |
| 55 | + |
| 56 | +2. Either copy your OAuth consumer secret and key and your access token secret and key into twittergeo/credentials.txt, or copy them into another file which you will specify on the command line. See credentials.txt for the expected file format. |
| 57 | + |
| 58 | +3. Then, run a script type with '-m' option, for example: |
| 59 | + |
| 60 | +`python -m twittergeo.StreamGeo zzz` |
| 61 | +`python -m twittergeo.StreamGeo zzz -oauth ./my_credentials.txt` |
| 62 | + |
| 63 | +# External Dependencies # |
| 64 | + |
| 65 | +This package uses the following external packages. |
| 66 | + |
| 67 | +* twitterapi - for downloading tweets |
| 68 | +* pygeocoder - for geo-referencing using Google's Maps service |
| 69 | +* fridge - for caching latitudes and longitudes in a persistant dict |
| 70 | + |
| 71 | +# Contributors # |
| 72 | + |
| 73 | +Jonas Geduldig |
0 commit comments