当前位置: 首页>>代码示例>>Python>>正文


Python API.search方法代码示例

本文整理汇总了Python中api.API.search方法的典型用法代码示例。如果您正苦于以下问题:Python API.search方法的具体用法?Python API.search怎么用?Python API.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在api.API的用法示例。


在下文中一共展示了API.search方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SinaAPI

# 需要导入模块: from api import API [as 别名]
# 或者: from api.API import search [as 别名]

#.........这里部分代码省略.........
    def comment(self, comment, mid, cid=None):
        logger.info('api-nail')
        status = self.api.comment(id=mid, comment=comment, comment_ori=0)
        ncid = self.getAttValue(status,"id")
        text = self.getAttValue(status,"text")
        return ncid

    @check_remain_requests('Too many requests in comment')
    def reply(self, comment, sid, cid):
        logger.info('api-nail')
        status = self.api.reply(id=sid,cid=cid,comment=comment, without_mention=True)
        ncid = self.getAttValue(status,"id")
        text = self.getAttValue(status,"text")
        return ncid
        
    @check_remain_requests('Too many requests in commentDestroy')
    def commentDestroy(self, cid):
        status = self.api.comment_destroy(cid)
        ncid = self.getAttValue(status,"id")
        text = self.getAttValue(status,"text")

    @check_remain_requests('Too many requests in uploadResult')
    def uploadResult(self, contents, status,contenttype="image/png"):
        logger.info('api-nail')
        status = self.api.upload_result(contents, status,contenttype=contenttype)
        ncid = self.getAttValue(status, "id")
        text = self.getAttValue(status, "text")
        return status

    @check_remain_requests('Too many requests in upload')
    def upload(self, filename, status):
        logger.info('api-nail')
        status = self.api.upload(filename, status)
        ncid = self.getAttValue(status, "id")
        text = self.getAttValue(status, "text")

    @check_remain_requests('Too many requests in createFriendship')
    def createFriendship(self,user_id):
        logger.info('api-nail')
        user = self.api.create_friendship(user_id=user_id)
        return user

    @check_remain_requests('Too many requests in destoryFriendship')
    def destroyFriendship(self,user_id):
        logger.info('api-nail')
        user = self.api.destroy_friendship(user_id=user_id)
        return user

    def getRateLimit(self):
        logger.info('api-nail')
        return self.api.rate_limit_status()


    @check_remain_requests('Too many requests in destoryFriendship')
    def getTrendsStatus(self, trend, province=0, count=200, page=1):
        status = self.api.trends_statuses(
            trend=trend,
            count=count, 
            page=page
        )
        return status


    @check_remain_requests('Too many requests in destoryFriendship')
    def ShowStatus(self, sid):
        logger.info('api-nail')
        return self.api.statuses_show(id=sid)


    def getSearchStatus(self, q, since_id=-1):
        rst_list = []
        
        for i in range(30):
            try:
                status = self.api.search(q, since_id=since_id)
            except Exception as e:
                return rst_list
            
            rst_list.extend(status)
            since_id = status[-1]

        return rst_list 

    def getSearchUser(self, q, page=1):
        rst_list = []
        for i in range(1, 10):
            try:
                status = self.api.search_user(q, page=i)
            except Exception as e:
                return rst_list
            
            rst_list.extend(status)

        return rst_list 

    def get_short_url_share_counts(
        self,
        url_short,
    ):
        return self.api.short_url_share_counts(url_short=url_short)
开发者ID:seraphlnWu,项目名称:weibosdk,代码行数:104,代码来源:sinaapi.py


注:本文中的api.API.search方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。