data points
Scrapes Twitter to find "Mood of the World". This is based Twitter Mood Light project by RandomMatrix
| Time Recorded (time1236) | Data (data1236) |
|---|---|
| 21 May 2013 09:30:12 | [88.6080941254302] |
| 20 May 2013 09:30:13 | [93.3956379529416] |
| 19 May 2013 09:30:12 | [112.219450648063] |
| 18 May 2013 09:30:12 | [96.6057992236904] |
| 17 May 2013 09:30:13 | [84.5864659829819] |
% Scrapes Twitter to find "Mood of the World".
% This is based
% <http://www.instructables.com/id/Twitter-Mood-Light-The-Worlds-Mood-in-a-Box/ Twitter Mood Light> project by <http://www.instructables.com/member/RandomMatrix/ RandomMatrix>
% Note: Trendy only runs this script 1/day
% Twitter limits search results to ~1500 tweets
% Therefore, this search covers a small amount of time (perhaps only minutes), and is not representative of an entire day
% Max Tweets/page limited to 100 by Twitter.com
% Regular expression for pulling out dates/times
exp = '((31(?!\ (Feb(ruary)?|Apr(il)?|June?|(Sep(?=\b|t)t?|Nov)(ember)?)))|((30|29)(?!\ Feb(ruary)?))|(29(?=\ Feb(ruary)?\ (((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\d|2[0-8])\ (Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\b|t)t?|Nov|Dec)(ember)?)\ ((1[6-9]|[2-9]\d)\d{2}) (([0-9])|([0-1][0-9])|([2][0-3])):(([0-9])|([0-5][0-9])):(([0-9])|([0-5][0-9]))[^[0-9]]';
urlHost = 'http://search.twitter.com/search.json';
% 1. Love
search{1} = '?q="i+love+you"+OR+"i+love+her"+OR+"i+love+him"+OR+"all+my+love"+OR+"i''m+in+love"+OR+"i+really+love"&rpp=100&result_type=recent';
emotion{1} = 'Love ';
% 2. Joy
search{2} = '?q="happiest"+OR+"so+happy"+OR+"so+excited"+OR+"i''m+happy"+OR+"woot"+OR+"w00t"&rpp=100&result_type=recent';
emotion{2} = 'Joy ';
% 3. Surprise
search{3} = '?q="wow"+OR+"O_o"+OR+"can''t+believe"+OR+"wtf"+OR+"unbelievable"&rpp=100&result_type=recent';
emotion{3} = 'Surprise ';
% 4. Anger
search{4} = '?q="i+hate"+OR+"really+angry"+OR+"i+am+mad"+OR+"really+hate"+OR+"so+angry"&rpp=100&result_type=recent';
emotion{4} = 'Anger ';
% 5. Envy
search{5} = '?q="i+wish+i"+OR+"i''m+envious"+OR+"i''m+jealous"+OR+"i+want+to+be"+OR+"why+can''t+i"+&rpp=100&result_type=recent';
emotion{5} = 'Envy ';
% 6. Sadness
search{6} = '?q="i''m+so+sad"+OR+"i''m+heartbroken"+OR+"i''m+so+upset"+OR+"i''m+depressed"+OR+"i+can''t+stop+crying"&rpp=100&result_type=recent';
emotion{6} = 'Sadness ';
% 7. Fear
search{7} = '?q="i''m+so+scared"+OR+"i''m+really+scared"+OR+"i''m+terrified"+OR+"i''m+really+afraid"+OR+"so+scared+i"&rpp=100&result_type=recent';
emotion{7} = 'Fear ';
disp('Emotion Tweets/min, MinutesCovered')
% I didn't realize "Trends" are scalars
% for loop=1:length(search)
loop = 5;
url = [urlHost search{loop}];
page = urlread(url);
matches=regexp(page, exp, 'match');
time1 = datenum(matches{1});
url = [urlHost search{loop} '&page=15'];
page = urlread(url);
matches=regexp(page, exp, 'match');
time2 = datenum(matches{end});
seconds = (time1-time2)*24*60*60;
tweetsPerMinute = (1400+length(matches))/(seconds / 60);
disp([emotion{loop} num2str(tweetsPerMinute) ', ' num2str(seconds/60)])
% end
updatetrend(tweetsPerMinute);
0 comments