main.py 文件源码

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

项目:SinaWeibo 作者: chengshuyi 项目源码 文件源码
def getOneWeibo():
    reason=['????','??','????????','????','??????','????','??????','????','????','?????']
    db=get_db()
    cl=db['retweet']
    rst=cl.find({'retweet':0}).sort("mid", pymongo.ASCENDING)
    for rt in rst:
        cl.update({'_id':rt['_id']},{'$set':{'retweet':1}})
        print('update',rt['mid'],' retweet=1')
        if len(rt['url'])>4:
            print(rt['mid'],' too many users to follow,find another weibo')
            continue
        rt['reason']=reason[random.randint(0,len(reason)-1)]
        if rt['friend']>0:
            cl=db['follow']
            rst=cl.find({'follow':1})
            rint=random.randint(0,rst.count()-rt['friend'])
            for i in range(rint,rint+rt['friend']):
                rt['reason']=rt['reason']+'@'+rst[i]['nick']+' '
        return rt
    return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号