skip to Main Content

I am trying to extract two values:

  1. iid
  2. device_id
{
    'Cookies': {
        'install_id': '7296374090783672107',
        'store-country-code': 'us',
        'store-country-code-src': 'did',
        'store-idc': 'useast5',
        'ttreq': '1$ae2625a14f85ea1578eaedbecdca21116587d1bf'
     },
     'Device_Info': {
         'ab_version': '31.9.1',
         'ac': 'wifi',
         'ac2': 'wifi',
         'aid': '1233',
         ...,
         'device_brand': 'oneplus',
         'device_id': '7296372688908764714',
         'device_platform': 'android',
         'device_type': 'ONEPLUS_NGQH7',
         'dpi': '240',
         'host_abi': 'armeabi-v7a',
         'iid': '7296374090783672107',
         'language': 'en', 
         ...,
         'version_name': '31.9.1'
    },
    'Ri_Report': True,
    'Seed_Algorithm': 2,
    'Seed_Token': 'MDGnH5rXrXMBLDp4yW1hxNLnzLN7HSImBjd7qvgHS0/UexbRR2Q6EFV1Rk6wNQCm2egOLgjHyxeduQ7OUKyjVlOTmzTdVrcGLt9nmkBD7jRq/pQQFrzl9S0VZnmO6N7NA/E=',
    'is_activated': 'success',
    'secDeviceIdToken': 'AYsl1BnO6yj0P-bRtl7FXBbSD'
}

Tried Find, tried to convert it to json.

with failed attempt. am new into python hopefully somebody can give me a hand. Thank you.

2

Answers


  1. myObjYour code already appears to be a Python dictionary. I was able to do the following

    myObj = {
        'Cookies': {
            'install_id': '7296374090783672107',
            'store-country-code': 'us',
            'store-country-code-src': 'did',
            'store-idc': 'useast5',
            'ttreq': '1$ae2625a14f85ea1578eaedbecdca21116587d1bf'
         },
         'Device_Info': {
             'ab_version': '31.9.1',
             'ac': 'wifi',
             'ac2': 'wifi',
             'aid': '1233',
             'device_brand': 'oneplus',
             'device_id': '7296372688908764714',
             'device_platform': 'android',
             'device_type': 'ONEPLUS_NGQH7',
             'dpi': '240',
             'host_abi': 'armeabi-v7a',
             'iid': '7296374090783672107',
             'language': 'en', 
             'version_name': '31.9.1'
        },
        'Ri_Report': True,
        'Seed_Algorithm': 2,
        'Seed_Token': 'MDGnH5rXrXMBLDp4yW1hxNLnzLN7HSImBjd7qvgHS0/UexbRR2Q6EFV1Rk6wNQCm2egOLgjHyxeduQ7OUKyjVlOTmzTdVrcGLt9nmkBD7jRq/pQQFrzl9S0VZnmO6N7NA/E=',
        'is_activated': 'success',
        'secDeviceIdToken': 'AYsl1BnO6yj0P-bRtl7FXBbSD'
    }
    
    print(myObj["Device_Info"]["iid"])
    
    Login or Signup to reply.
  2. Try the following capture patterns.

    'iid':s*'(.+?)'
    
    'device_id':s*'(.+?)'
    

    Here is an example.

    a = re.search(r"'iid':s*'(.+?)'", s)
    b = re.search(r"'device_id':s*'(.+?)'", s)
    iid, device_id = a.group(1), b.group(1)
    

    Output

    7296374090783672107
    7296372688908764714
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search