def inner(): l = Loklak() tweets = l.search('fossasia') # for tweet in tweets['statuses']: # time.sleep(1) # Don't need this just shows the text streaming # yield tweet.text for i in range(0, 10000): yield i
def ajaxwall(query=None): q = query l = Loklak() tweets = l.search(q) for tweet in tweets['statuses']: try: imageUrl = tweet['user']['profile_image_url_https'] newUrl = imageUrl.split('_bigger') updatedUrl = newUrl[0] + newUrl[1] tweet['user']['profile_image_url_https'] = updatedUrl except: pass return json_response(tweets)
def visualize(): q = request.form['q'] l = Loklak() data = l.search(q) statuses = data['statuses'] if(len(statuses) == 0): return render_template('404.html') emotions = [] languages = [] countries = [] for status in statuses: try: emotion = status['classifier_emotion'] language = status['classifier_language'] place = status['place_country'] emotions.append(emotion) languages.append(language) countries.append(place) except: pass pprint(emotions) pprint(languages) pprint(countries) try: languageDict = dict(list(Counter(languages).items())) pprint(languageDict) except: pass try: emotionDict = dict(list(Counter(emotions).items())) pprint(emotionDict) except: pass try: countryDict = dict(list(Counter(countries).items())) pprint(countryDict) except: pass languageInfo = {} emotionInfo = {} countryInfo = {} for key, value in languageDict.iteritems(): languageInfo[str(key)] = value for key, value in emotionDict.iteritems(): emotionInfo[str(key)] = value for key, value in countryDict.iteritems(): countryInfo[str(key)] = value return render_template('result.html', q=q, languages=languageInfo, emotions=emotionInfo, country=countryInfo, statuses=statuses)
def wall(query=None): q = query l = Loklak() tweets = l.search(q) for tweet in tweets['statuses']: try: imageUrl = tweet['user']['profile_image_url_https'] newUrl = imageUrl.split('_bigger') updatedUrl = newUrl[0] + newUrl[1] tweet['user']['profile_image_url_https'] = updatedUrl except: pass return render_template('index3.html', name=q, tweets=tweets, BASE_URL=BASE_URL)
def get_tweets(hashtag, since=0, count=100): """ Fetches all tweets to a given hashtag :param hashtag: (str) keyword :param since: (str) Y-M-D :param count: (int) count :return: (list, int, int) 1. Content, 2. """ l = Loklak() since = datetime.datetime.now() + datetime.timedelta(days=-since) since = datetime.datetime.strftime(since, "%Y-%m-%d") tweet_list = [] for t in l.search(hashtag, since=since, count=count)["statuses"]: tweet_list.append(t["text"]) return tweet_list #, len(tweet_list), since
def wall(query=None): q = query l = Loklak() tweets = l.search(q) return render_template('index.html', name=q, tweets=tweets)
def ajaxwall(query=None): q = query l = Loklak() tweets = l.search(q) return json_response(tweets)
def setUp(self): """Test proper setup.""" self.loklak = Loklak(self.baseUrl)
#!/usr/bin/env python # encoding: utf-8 """This module contains an example of retrieving tweets using search() function and print them in the console.""" import sys from loklak import Loklak query = sys.argv[1] l = Loklak() print("Retrieving Tweets...") tweets = l.search(query) for tweet in tweets['statuses']: print('@' + str(tweet['screen_name']) + ': ' + str(tweet['text']))
import time import sys import pprint import uuid from uuid import getnode as get_mac from loklak import Loklak import string import random # Global loklak object loklakConnectionObject = Loklak() def generateID(): return ''.join(random.sample(string.letters*12,12)) import RPi.GPIO as GPIO import time GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(3,GPIO.OUT,pull_up_down=GPIO.PUD_DOWN) GPIO.setup(7,GPIO.IN,pull_up_down=GPIO.PUD_UP) GPIO.setup(11,GPIO.IN) ls='OFF' try: import ibmiotf.application import ibmiotf.device except ImportError: # This part is only required to run the sample from within the samples # directory when the module itself is not installed.
"""This module contains an example for searching the tweets using search() function in loklak.py.""" from loklak import Loklak myTweets = Loklak() movieName = raw_input("What movie would you like to \ search recent tweets for? ") #asks for what user would like to search for index = 1 for tweet in myTweets.search( movieName )["statuses"]: #searches movie and finds "statuses" where "text" is under print("%d%s", index, '.') #prints the tweet number print("%s\n", tweet["text"]) #prints the text of the tweet and makes a new line index += 1 #increments index