import json
import pathlib

from pymongo import MongoClient

client = MongoClient('mongodb://root:123456@74.48.159.194:27017/?authSource=admin&directConnection=true')
db = client.test
# 查询所有文档
#platform.uname().system != 'Darwin' and not
if pathlib.Path('env.json').exists():
    # , 'success': {'$gte': 30}
    # , 'env.navigatorparams.useragent': {'$regex': 'iPhone'}
    # result = db.env_shape.find({'env.funcs' :{'$ne': None}})
    result = db.env.find()
    data = {}
    for x in result:
        # if '₹' in x['env']['fontsres']['1000px monospace']:
        _id = str(x['_id'])
        x.pop('_id')
        data[_id] = x


    print(result)
    with open('env.json', 'w', encoding='utf-8') as f:
        f.write(json.dumps(data))