微博展开全文获取

pc端

    def getlongtext(self,mid:str,req:requests)->"获取全文逻辑":
        allinfo=None
        getlongtexturl=f"http://s.weibo.com/ajax/direct/morethan140?mid={mid}"
        resp=req.get(getlongtexturl,timeout=60).json()
        okcode=resp["code"]
        if okcode=="100000":
            allinfo=resp["data"]["html"]
        else:
            print("get log text is error,here are detail:{}",traceback.format_exc())
        return allinfo

h5端

    def getlongtext(self,mid:str,req:requests)->"获取全文逻辑":
        allinfo=None
        getlongtexturl=f"https://m.weibo.cn/statuses/extend?id={mid}"
        resp=req.get(getlongtexturl,timeout=60).json()
        okcode=resp["ok"]
        if okcode==1:
            allinfo=resp["data"]["longTextContent"]
        else:
            print("get log text is error,here are detail:{}",traceback.format_exc())
        return allinfo
posted @ 2018-07-20 16:04  公众号python学习开发  阅读(1253)  评论(0编辑  收藏  举报