Example #1
0
def foodporn():
    search_term = "#foodporn"
    query = Query(search_term,
                  limit=400,
                  qFilter=Query.ImageFitler,
                  plugins=[SentimentPlugin()])
    save(search_term, query.get_results())
Example #2
0
def zika():
    search_term = "#zika"
    fields = {
        'x': 'x',
        'y': 'y',
        'country_code': 'country_code',
        'city': 'city',
        'text': 'text',
        'lang': 'lang',
        'screen_name': 'screen_name',
        'timestamp': 'timestamp',
        'created_at': 'created_at'
    }
    now = int(time.time())
    start_time = parseTime("2016-02-01")
    one_hour = 60 * 60
    tweets = []
    binned_tweets = []
    while start_time < now:
        start_time += one_hour
        query = Query(tag=search_term,
                      start_s=start_time,
                      duration_s=60 * 20,
                      limit=200,
                      qFilter=Query.PlaceFilter,
                      plugins=[PlacePlugin(),
                               LimitedFields(fields)])
        new = query.get_results()
        tweets = tweets + new
        binned_tweets.append({
            'count': len(new),
            'start_time': start_time,
            'tweets': new
        })
        print len(new)
        if len(tweets) > 0:
            first = tweets[0]
            last = tweets[-1]
            print "first: %(first)s, last: %(last)s" % {
                'first': first.get('created_at'),
                'last': last.get('created_at')
            }
        else:
            print "."
        save(search_term, tweets)
        save(search_term + "_binned", binned_tweets)
Example #3
0
def zika():
    search_term = "#zika"
    fields = {
        'x': 'x',
        'y': 'y',
        'country_code': 'country_code',
        'city': 'city',
        'text': 'text',
        'lang': 'lang',
        'screen_name': 'screen_name',
        'timestamp': 'timestamp'
    }
    query = Query(search_term, limit=20, qFilter=Query.PlaceFilter, plugins=[PlacePlugin(), LimitedFields(fields)])
    tweets = query.get_results()
    for tweet in tweets:
        print tweet.get('screen_name')
    save(search_term, tweets)
Example #4
0
File: main.py Project: knowuh/IDV2
def cara():
    fields = { 'category': 'category', 'text': 'text', 'screen_name': 'screen_name', 'timestamp': 'timestamp' }
    candidates = [
        {'name': 'trump', 'terms': ['#Trump2016', '#MakeAmericaGreatAgain', '#TrumpForPresident2016']},
        {'name': 'cruz',  'terms': ['#TedCruz',   '#CruzCrew', '#TedCruz2016']},
        {'name': 'clinton', 'terms': ['#Hillary2016', '#ImWithHer', '#Hillary']},
        {'name': 'sanders', 'terms': ['#Bernie2016', '#FeelTheBern', '#VoteBernie']}
    ]
    issues = {}
    for candidate in candidates:
        candidate_name = candidate.get('name')
        issues[candidate_name] = Counter()
        for term in candidate.get('terms'):
            query = Query(term, limit=400, plugins=[CategoryPlugin(), LimitedFields(fields)])
            tweets = query.get_results()
            for tweet in tweets:
                issues[candidate_name].update(tweet.get('category'))
    print json.dumps(issues, indent=4, sort_keys=True)
    save('cara', issues)
Example #5
0
def cara():
    fields = { 'category': 'category', 'text': 'text', 'screen_name': 'screen_name', 'timestamp': 'timestamp' }
    candidates = [
        {'name': 'trump', 'terms': ['#Trump2016', '#MakeAmericaGreatAgain', '#TrumpForPresident2016']},
        {'name': 'cruz',  'terms': ['#TedCruz',   '#CruzCrew', '#TedCruz2016']},
        {'name': 'clinton', 'terms': ['#Hillary2016', '#ImWithHer', '#Hillary']},
        {'name': 'sanders', 'terms': ['#Bernie2016', '#FeelTheBern', '#VoteBernie']}
    ]
    issues = {}
    for candidate in candidates:
        candidate_name = candidate.get('name')
        issues[candidate_name] = Counter()
        for term in candidate.get('terms'):
            query = Query(term, limit=400, plugins=[CategoryPlugin(), LimitedFields(fields)])
            tweets = query.get_results()
            for tweet in tweets:
                issues[candidate_name].update(tweet.get('category'))
    print json.dumps(issues, indent=4, sort_keys=True)
    save('cara', issues)
Example #6
0
def panama():
    search_term = "panama papers"
    fields = {
        'x': 'x',
        'y': 'y',
        'country_code': 'country_code',
        'city': 'city',
        'text': 'text',
        'lang': 'lang',
        'screen_name': 'screen_name',
        'timestamp': 'timestamp',
        'created_at': 'created_at'
    }

    query = Query(tag=search_term,
                  limit=4000,
                  qFilter=Query.PlaceFilter,
                  plugins=[PlacePlugin(), LimitedFields(fields)])
    tweets = query.get_results()
    save(search_term, tweets)
Example #7
0
File: main.py Project: knowuh/IDV2
def panama():
    search_term = "panama papers"
    fields = {
        'x': 'x',
        'y': 'y',
        'country_code': 'country_code',
        'city': 'city',
        'text': 'text',
        'lang': 'lang',
        'screen_name': 'screen_name',
        'timestamp': 'timestamp',
        'created_at': 'created_at'
    }

    query = Query(
        tag=search_term,
        limit=4000,
        qFilter=Query.PlaceFilter,
        plugins=[PlacePlugin(), LimitedFields(fields)])
    tweets = query.get_results()
    save(search_term, tweets)
Example #8
0
File: main.py Project: knowuh/IDV2
def zika():
    search_term = "#zika"
    fields = {
        'x': 'x',
        'y': 'y',
        'country_code': 'country_code',
        'city': 'city',
        'text': 'text',
        'lang': 'lang',
        'screen_name': 'screen_name',
        'timestamp': 'timestamp',
        'created_at': 'created_at'
    }
    now = int(time.time())
    start_time = parseTime("2016-02-01")
    one_hour = 60 * 60
    tweets = []
    binned_tweets = []
    while start_time < now:
        start_time += one_hour
        query = Query(
            tag=search_term,
            start_s=start_time,
            duration_s= 60 * 20,
            limit=200,
            qFilter=Query.PlaceFilter,
            plugins=[PlacePlugin(), LimitedFields(fields)])
        new = query.get_results()
        tweets = tweets + new
        binned_tweets.append({'count': len(new), 'start_time': start_time, 'tweets': new})
        print len(new)
        if len(tweets) > 0:
            first = tweets[0]
            last  = tweets[-1]
            print "first: %(first)s, last: %(last)s" % { 'first': first.get('created_at'), 'last': last.get('created_at')}
        else:
            print "."
        save(search_term, tweets)
        save(search_term + "_binned", binned_tweets)
Example #9
0
File: main.py Project: knowuh/IDV2
def foodporn():
    search_term = "#foodporn"
    query = Query(search_term, limit=400, qFilter=Query.ImageFitler, plugins=[SentimentPlugin()])
    save(search_term, query.get_results())
Example #10
0
def fashion():
    search_term = "#fashion"
    query = Query(search_term, limit=50, qFilter=Query.ImageFitler)
    save(search_term, query.get_results())