从JSON嵌套对象中提取特定对象

时间:2020-07-09 16:20:05

标签: python jupyter-notebook

我只想从Get请求的以下JSON输出中提取 Name,Domain,logo 。你能告诉我如何解决这个问题吗?

此外,到目前为止,每个请求的有效负载为200。如何将请求循环到select *之类的响应结束,但是循环多个请求

我的JSON

{
  "has_more": true,
  "last_val": "HomeServe",
  "merchants": [
    {
      "advertiser_id": 42605,
      "calculated_average_daily_sales": 1193.33,
      "calculated_average_order_value": 0.33617931384000005,
      "calculated_ecpc": 0.011473260818400001,
      "countries": [
        "Mexico",
        "Poland",
        "Nicaragua"
      ],
      "domain": "tripadvisor.com",
      "domains": [
        "tripadvisor.com",
        "tripadvisor.co.uk",
      ],
      "exclusive": false,
      "favourite": false,
      "id": 459557,
      "maximum_rate": {
        "aggregation_type": "maximum",
        "base_rate": 20,
       },
      "merchant_id": 459557,
      "metadata": {
        "description": null,
        "logo": "https://static.testinks.com/images/merchant_logos/1222_925b6b63517f7tttaf2b4ccce744295bc.png",
        "special_conditions": "Commission is only available for hotels on Tripadvisor."
      },
      "minimum_rate": {
        "aggregation_type": "minimum",
        "base_rate": 20,
      },
      "name": "TripAdvisor",
      "network_payout_types": [
        "performance-based"
      ],
      "partner_type": "preferred",
      "program_payout_type": [
        "cpa"
      ],
      "verticals": [
        {
          "vertical_id": 4,
          "vertical_name": "Package Holidays"
        },
        {
          "vertical_id": 5,
          "vertical_name": "Flights"
        }
      ]
    },
    ....
    ....
    ..

我尝试过的事情

    import requests
    import csv
    import json
    import pandas as pd
    
    guri="https://private-anon-73f9ac5d87-testlinssmerchantapi.apiary-proxy.com/v4/publisher/12567/merchants?access_token=99999%3A1594309998%3Adf3ce9fb99997e2a53d282562d9b9d26&country=US"
    rt = requests.get(guri)
    
    df = pd.json_normalize(rt.json())
    print (df['merchants'][0]['attribute']['logo']['value'])
    

0 个答案:

没有答案
相关问题