MongoHelper.py 文件源码

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

项目:IPProxyPool 作者: qiyeboy 项目源码 文件源码
def select(self, count=None, conditions=None):
        if count:
            count = int(count)
        else:
            count = 0
        if conditions:
            conditions = dict(conditions)
            conditions_name = ['types', 'protocol']
            for condition_name in conditions_name:
                value = conditions.get(condition_name, None)
                if value:
                    conditions[condition_name] = int(value)
        else:
            conditions = {}
        items = self.proxys.find(conditions, limit=count).sort(
            [("speed", pymongo.ASCENDING), ("score", pymongo.DESCENDING)])
        results = []
        for item in items:
            result = (item['ip'], item['port'], item['score'])
            results.append(result)
        return results
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号