正在寻求有关分析字典对象的帮助

2024-06-17 12:03:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我在下面有一个dictionary对象:

{'@context': 'http://schema.org/',
 '@type': 'ItemList',
 'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz',
 'numberOfItems': '921',
 'itemListElement': [{'@type': 'ListItem',
   'position': '1',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/B0000/2000/BB2345/thumbnail/f.jpg?var=1562137579',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/BB2345',
    'description': 'StockId:BB2345 Hatchback PS, AC, AB, ABS, PW 2WD 990 F ADVANCED EDITION PETROL AT Blue(L) 1KR DBA-KSP90 TOYOTA VITZ BACK CAMERA,HID',
    'name': 'TOYOTA VITZ',
    'mpn': 'BB2345',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '482',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '51000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '2',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/X0000/3000/AX3520/thumbnail/f.jpg?var=1569499362',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/AX3520',
    'description': 'StockId:AX3520 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Silver 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'AX3520',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '519',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '55000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '3',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/U0000/7000/FU7141/thumbnail/f.jpg?var=1578556966',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/FU7141',
    'description': 'StockId:FU7141 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Red 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'FU7141',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '529',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '56000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '4',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/M0000/3000/TM3442/thumbnail/f.jpg?var=1570007145',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/TM3442',
    'description': 'StockId:TM3442 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Silver 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'TM3442',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '548',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '58000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '5',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/G0000/1000/VG1142/thumbnail/f.jpg?var=1571061702',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/VG1142',
    'description': 'StockId:VG1142 Hatchback PS, AC, AW, AB, ABS, PW 2WD 990 F PETROL AT Blue(L) 1KR DBA-KSP90 TOYOTA VITZ CD/PUSH START',
    'name': 'TOYOTA VITZ',
    'mpn': 'VG1142',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '548',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '58000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '6',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/Q0000/2000/SQ2312/thumbnail/f.jpg?var=1571925700',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/SQ2312',
    'description': 'StockId:SQ2312 Hatchback PS, AC, NV, AB, ABS, PW 2WD 990 F PETROL AT Gray 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'SQ2312',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '557',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '59000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '7',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/Q0000/2000/GQ2150/thumbnail/f.jpg?var=1573031189',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/GQ2150',
    'description': 'StockId:GQ2150 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Blue(L) 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'GQ2150',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '557',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '59000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '8',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/Z0000/2000/KZ2901/thumbnail/f.jpg?var=1574089452',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/KZ2901',
    'description': 'StockId:KZ2901 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Silver 1KR DBA-KSP90 TOYOTA VITZ CD',
    'name': 'TOYOTA VITZ',
    'mpn': 'KZ2901',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '557',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '59000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '9',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/Z0000/9000/SZ9981/thumbnail/f.jpg?var=1574845730',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/SZ9981',
    'description': 'StockId:SZ9981 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Silver 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'SZ9981',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '557',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '59000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '10',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/L0000/3000/XL3022/thumbnail/f.jpg?var=1574845814',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/XL3022',
    'description': 'StockId:XL3022 Hatchback PS, AC, AB, ABS, PW 2WD 990 F ADVANCED EDITION PETROL AT Black 1KR DBA-KSP90 TOYOTA VITZ HID',
    'name': 'TOYOTA VITZ',
    'mpn': 'XL3022',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '567',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '60000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '11',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/N0000/4000/VN4983/thumbnail/f.jpg?var=1575533162',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/VN4983',
    'description': 'StockId:VN4983 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Blue(D) 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'VN4983',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '567',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '60000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '12',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/V0000/1000/MV1531/thumbnail/f.jpg?var=1573545654',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/MV1531',
    'description': 'StockId:MV1531 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Blue(L) 1KR DBA-KSP90 TOYOTA VITZ CD',
    'name': 'TOYOTA VITZ',
    'mpn': 'MV1531',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '567',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '60000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '13',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/W0000/1000/VW1001/thumbnail/f.jpg?var=1579086417',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/VW1001',
    'description': 'StockId:VW1001 Hatchback PS, AC, AB, ABS, PW 2WD 990 1.0F PETROL AT Black 1KR DBA-KSP90 TOYOTA VITZ CD',
    'name': 'TOYOTA VITZ',
    'mpn': 'VW1001',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '576',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '61000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '14',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/D0000/3000/ND3480/thumbnail/f.jpg?var=1576065900',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/ND3480',
    'description': 'StockId:ND3480 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Silver 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'ND3480',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '585',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '62000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '15',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/U0000/7000/EU7269/thumbnail/f.jpg?var=1574924644',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/EU7269',
    'description': 'StockId:EU7269 Hatchback PS, AC, NV, AB, ABS, PW 2WD 990 F ADVANCED EDITION PETROL AT Blue(D) 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'EU7269',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '585',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '62000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '16',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/A0000/0000/MA0915/thumbnail/f.jpg?var=1574337614',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/MA0915',
    'description': 'StockId:MA0915 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Black 1KR DBA-KSP90 TOYOTA VITZ CD PUSH START',
    'name': 'TOYOTA VITZ',
    'mpn': 'MA0915',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '595',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '63000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '17',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/G0000/5000/SG5313/thumbnail/f.jpg?var=1574759251',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/SG5313',
    'description': 'StockId:SG5313 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Silver 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'SG5313',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '595',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '63000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '18',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/L0000/5000/CL5235/thumbnail/f.jpg?var=1576483385',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/CL5235',
    'description': 'StockId:CL5235 Hatchback PS, AC, AW, AB, ABS, PW 2WD 990 F PETROL AT Blue(D) 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'CL5235',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '595',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '63000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '19',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/E0000/8000/OE8919/thumbnail/f.jpg?var=1576760451',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/OE8919',
    'description': 'StockId:OE8919 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Blue(D) 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'OE8919',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '595',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '63000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '20',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/U0000/6000/CU6730/thumbnail/f.jpg?var=1577271732',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/CU6730',
    'description': 'StockId:CU6730 Hatchback PS, AC, AB, ABS, PW 2WD 990 F CREAM COLLECTION PETROL AT Rose 1KR DBA-KSP90 TOYOTA VITZ PUSH START',
    'name': 'TOYOTA VITZ',
    'mpn': 'CU6730',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '595',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '63000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '21',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/C0000/1000/PC1280/thumbnail/f.jpg?var=1578276155',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/PC1280',
    'description': 'StockId:PC1280 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Silver 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'PC1280',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '595',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '63000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '22',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/Q0000/6000/DQ6012/thumbnail/f.jpg?var=1577278950',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/DQ6012',
    'description': 'StockId:DQ6012 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Blue(L) 1KR DBA-KSP90 TOYOTA VITZ CD',
    'name': 'TOYOTA VITZ',
    'mpn': 'DQ6012',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '614',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '65000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '23',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/K0000/5000/VK5067/thumbnail/f.jpg?var=1576220819',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/VK5067',
    'description': 'StockId:VK5067 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Blue(D) 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'VK5067',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '614',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '65000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '24',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/D0000/1000/JD1133/thumbnail/f.jpg?var=1575450617',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/JD1133',
    'description': 'StockId:JD1133 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Blue(L) 1KR DBA-KSP90 TOYOTA VITZ ',
    'name': 'TOYOTA VITZ',
    'mpn': 'JD1133',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '614',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '65000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}},
  {'@type': 'ListItem',
   'position': '25',
   'item': {'@type': 'Product',
    'image': 'https://srv1.sbtjapan.com/photo/J0000/1000/FJ1916/thumbnail/f.jpg?var=1581322607',
    'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/FJ1916',
    'description': 'StockId:FJ1916 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Blue(L) 1KR DBA-KSP90 TOYOTA VITZ CD',
    'name': 'TOYOTA VITZ',
    'mpn': 'FJ1916',
    'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
    'brand': {'@type': 'Brand', 'name': 'VITZ'},
    'offers': [{'@type': 'Offer',
      'priceCurrency': 'USD',
      'price': '614',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'},
     {'@type': 'Offer',
      'priceCurrency': 'JPY',
      'price': '65000',
      'itemCondition': 'http://schema.org/UsedCondition',
      'availability': 'http://schema.org/InStock'}]}}]}

如果类型(对象)我得到“dict”

print(site_json.keys())

我明白了

dict_keys(['@context', '@type', 'url', 'numberOfItems', 'itemListElement'])

我对提取itemListElement感兴趣 所以我尝试下面的代码:

items=object.get('itemListElement')

我得到:

[{'@type': 'ListItem',
  'position': '1',
  'item': {'@type': 'Product',
   'image': 'https://srv1.sbtjapan.com/photo/B0000/2000/BB2345/thumbnail/f.jpg?var=1562137579',
   'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/BB2345',
   'description': 'StockId:BB2345 Hatchback PS, AC, AB, ABS, PW 2WD 990 F ADVANCED EDITION PETROL AT Blue(L) 1KR DBA-KSP90 TOYOTA VITZ BACK CAMERA,HID',
   'name': 'TOYOTA VITZ',
   'mpn': 'BB2345',
   'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
   'brand': {'@type': 'Brand', 'name': 'VITZ'},
   'offers': [{'@type': 'Offer',
     'priceCurrency': 'USD',
     'price': '482',
     'itemCondition': 'http://schema.org/UsedCondition',
     'availability': 'http://schema.org/InStock'},
    {'@type': 'Offer',
     'priceCurrency': 'JPY',
     'price': '51000',
     'itemCondition': 'http://schema.org/UsedCondition',
     'availability': 'http://schema.org/InStock'}]}},
 {'@type': 'ListItem',
  'position': '2',
  'item': {'@type': 'Product',
   'image': 'https://srv1.sbtjapan.com/photo/X0000/3000/AX3520/thumbnail/f.jpg?var=1569499362',
   'url': 'https://www.sbtjapan.com/used-cars/toyota/vitz/AX3520',
   'description': 'StockId:AX3520 Hatchback PS, AC, AB, ABS, PW 2WD 990 F PETROL AT Silver 1KR DBA-KSP90 TOYOTA VITZ ',
   'name': 'TOYOTA VITZ',
   'mpn': 'AX3520',
   'manufacturer': {'@type': 'Organization', 'name': 'TOYOTA'},
   'brand': {'@type': 'Brand', 'name': 'VITZ'},
   'offers': [{'@type': 'Offer',
     'priceCurrency': 'USD',
     'price': '519',
     'itemCondition': 'http://schema.org/UsedCondition',
     'availability': 'http://schema.org/InStock'},
    {'@type': 'Offer',
     'priceCurrency': 'JPY',
     'price': '55000',
     'itemCondition': 'http://schema.org/UsedCondition',
     'availability': 'http://schema.org/InStock'}]}},

所以我得到了一份清单。 如何将列表转换为字典并提取: (1) 描述(2)名称(3)品牌(4)价格(5)价格货币(6)

欢迎任何提示

罗纳德


1条回答
网友
1楼 · 发布于 2024-06-17 12:03:44

通过遍历这些项,我找到了嵌套的字典和列表。 这里是我使用的代码

list_cars=[]
for i in  range(0, len(items)):
          car=items[i].get('item')
          desc=car.get('description')
          name=car.get('name')
          manu=car.get('manufacturer').get('name')
          brand=car.get('brand').get('name')
          pricecurusd=car.get('offers')[0].get('priceCurrency')
          priceusd=car.get('offers')[0].get('price')
          pricecuryen=car.get('offers')[1].get('priceCurrency')
          priceyen=car.get('offers')[1].get('price')
          l=[desc,name,manu,brand,pricecurusd,priceusd,pricecuryen,priceyen]
          list_cars.append(l)
import pandas as pd
df=pd.DataFrame(list_cars

相关问题 更多 >