Search tweets by keyword.

        Args:
            q: keyword

        Returns:
            list: tweet list
420512
def search(self, q):
        
        results = self._api.search(q=q)

        return results
1174646
def search(self, q, labels, state='open,closed', **kwargs):
        
        search_result = self.github_request.search(q=q, state=state, **kwargs)
        if search_result['total_count'] > 0:
            return list(
                map(lambda issue_dict: GithubIssue(
                    github_request=self.github_request, **issue_dict),
                    search_result['items'])
            )
1108970
def fetch_list_members(list_url):
    
    match = re.match(r'.+twitter\.com\/(.+)\/lists\/(.+)', list_url)
    if not match:
        print('cannot parse list url %s' % list_url)
        return []
    screen_name, slug = match.groups()
    print('collecting list %s/%s' % (screen_name, slug))
    return twutil.collect.list_members(slug, screen_name)
82719
def cmd(send, msg, args):
    
    if not msg:
        send('What do you think I am, a bird?')
        return

    parser = arguments.ArgParser(args['config'])
    parser.add_argument('query', nargs='*')
    group = parser.add_mutually_exclusive_group()
    group.add_argument('--user', dest='user', default=None)
    group.add_argument('--count', dest='count', type=int, default=1)
    group.add_argument('--random', action='store_true', default=False)

    try:
        cmdargs = parser.parse_args(msg)
    except arguments.ArgumentException as e:
        send(str(e))
        return

    api = get_search_api(args['config'])

    query = TwitterSearchOrder()
    keywords = [' '.join(cmdargs.query)]
    if cmdargs.user:
        keywords += ['from:{}'.format(cmdargs.user)]
    query.set_keywords(keywords)
    query.set_language('en')
    query.set_result_type('recent')
    query.set_include_entities(False)
    query.set_count(cmdargs.count)

    results = list(api.search_tweets_iterable(query))
    if not results:
        send('No tweets here!')
        return

    if cmdargs.random:
        shuffle(results)

    max_chan_tweets = 5
    max_pm_tweets = 25
    if cmdargs.count > max_pm_tweets:
        send("That's too many tweets! The maximum allowed through PM is {}".format(max_pm_tweets))
        return

    if cmdargs.count > max_chan_tweets:
        send("That's a lot of tweets! The maximum allowed in a channel is {}".format(max_chan_tweets))

    for i in range(0, min(cmdargs.count, max_pm_tweets)):
        if cmdargs.count <= max_chan_tweets:
            send(tweet_text(results[i]))
        else:
            send(tweet_text(results[i]), target=args['nick'])
1240538
def create_order_keyword_list(keywords):
     
    result = []
    for keyword in keywords:
        result.append((keyword, ''))
        result.append(('-%s' % keyword, ''))
    return result
1113071
def search(context, keywords, module, raw, kind):
    
    logging.info(_('Entering search mode'))
    sense = context.obj['sense']
    func = sense.query_names if module else sense.query_info
    none = True
    for keyword in keywords:
        output = func(keyword, raw, kind)
        if output:
            none = False
            print(output)
        else:
            logging.warning(_('No results: %s'), keyword)
    sys.exit(1 if none else 0)
236512
def search(self, q, **kw):
        """"""
        url = '{base_url}/search/{stream}'.format(**vars(self))

        params = {
            'q': q,
        }
        params.update(self.params)
        params.update(kw)

        response = self.session.get(url, params=params)
        response.raise_for_status()
        return response.json()
6163
def retweet?(status)
      filters = load_filters
      retweet = true
      if !filters.nil?
        filters.each_pair do |path, value|
          array = []
          array << value
          array.flatten.each do |filter_value|
            path_value = StreamBot::ArrayPath.get_path(status, path)
            if path_value.eql?(filter_value) || path_value.include?(filter_value)
              on_match.trigger(status, path, filter_value)
              retweet = false
            end
          end
        end
      end
      retweet
    end
401549
def messages(self, query, **kwargs):
        
        self.url = 'https://slack.com/api/search.messages'
        return super(Search, self).search_from_url(query, **kwargs)
985627
def lookup(self, id_list, **kw):
        
        result_id_pack = ','.join([str(_id) for _id in id_list])
        if not result_id_pack:
            return []
        return self.twitter.statuses.lookup(_id=result_id_pack)
619039
def search(self, keyword):
        
        params = {
            "source": "map",
            "description": keyword
        }
        data = self._request(ENDPOINTS['SEARCH'], params)
        data['result_data'] = [res for res in data['result_data'] if isinstance(res, dict)]
        return data
604189
def filter(self, **kwargs):
        
        from django.db.models import Q

        Statement = self.get_model('statement')

        kwargs.pop('page_size', 1000)
        order_by = kwargs.pop('order_by', None)
        tags = kwargs.pop('tags', [])
        exclude_text = kwargs.pop('exclude_text', None)
        exclude_text_words = kwargs.pop('exclude_text_words', [])
        persona_not_startswith = kwargs.pop('persona_not_startswith', None)
        search_text_contains = kwargs.pop('search_text_contains', None)

        # Convert a single sting into a list if only one tag is provided
        if type(tags) == str:
            tags = [tags]

        if tags:
            kwargs['tags__name__in'] = tags

        statements = Statement.objects.filter(**kwargs)

        if exclude_text:
            statements = statements.exclude(
                text__in=exclude_text
            )

        if exclude_text_words:
            or_query = [
                ~Q(text__icontains=word) for word in exclude_text_words
            ]

            statements = statements.filter(
                *or_query
            )

        if persona_not_startswith:
            statements = statements.exclude(
                persona__startswith='bot:'
            )

        if search_text_contains:
            or_query = Q()

            for word in search_text_contains.split(' '):
                or_query |= Q(search_text__contains=word)

            statements = statements.filter(
                or_query
            )

        if order_by:
            statements = statements.order_by(*order_by)

        for statement in statements.iterator():
            yield statement
476309
def show_keyword_help(cur, arg):
    
    keyword = arg.strip('"').strip("'")
    query = "help '{0}'".format(keyword)
    log.debug(query)
    cur.execute(query)
    if cur.description and cur.rowcount > 0:
        headers = [x[0] for x in cur.description]
        return [(None, cur.fetchall(), headers, '')]
    else:
        return [(None, None, None, 'No help found for {0}.'.format(keyword))]
1339545
def retweets(self, tweet_id):
        
        log.info("retrieving retweets of %s", tweet_id)
        url = "https://api.twitter.com/1.1/statuses/retweets/""{}.json".format(
                tweet_id)

        resp = self.get(url, params={"count": 100})
        for tweet in resp.json():
            yield tweet
962789
def get_dweets_for(thing_name, key=None, session=None):
    
    if key is not None:
        params = {'key': key}
    else:
        params = None
    return _request('get', '/get/dweets/for/{0}'.format(thing_name), params=params, session=None)
652209
def tweets_default(*args):
    
    query_type = settings.TWITTER_DEFAULT_QUERY_TYPE
    args = (settings.TWITTER_DEFAULT_QUERY,
            settings.TWITTER_DEFAULT_NUM_TWEETS)
    per_user = None
    if query_type == QUERY_TYPE_LIST:
        per_user = 1
    return tweets_for(query_type, args, per_user=per_user)
164978
def search(query, model):
    
    query = query.strip()
    LOGGER.debug(query)
    sqs = SearchQuerySet()
    results = sqs.raw_search('{}*'.format(query)).models(model)
    if not results:
        results = sqs.raw_search('*{}'.format(query)).models(model)
    if not results:
        results = sqs.raw_search('*{}*'.format(query)).models(model)

    return [o.pk for o in results]