tweets.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:python-twitter-toolbox 作者: hhromic 项目源码 文件源码
def search(writer, query, since_id=0):
    """Get hydrated Tweet-objects using the Search API."""
    LOGGER.info("search() starting")

    # initialize config and Twitter API
    config = read_config()
    api = get_app_auth_api(config)

    # process the query, storing returned Tweets in JSON format
    num_tweets = 0
    search_params = {
        "q": query,
        "count": SEARCH_COUNT,
        "result_type": "recent",
    }
    if since_id > 0:
        search_params.update({"since_id": since_id})
    limit = config.getint("search", "limit")
    try:
        num_tweets = write_objs(writer, api.search, search_params,
                                cursored=True, limit=limit)
        LOGGER.info("downloaded %d Tweet(s)", num_tweets)
    except TweepError as err:
        log_tweep_error(LOGGER, err)

    # finished
    LOGGER.info("search() finished")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号