[Python] Save json request to a file [duplicate]

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    thanks for your attention!

    I'm doing a for loop and "requesting url" here on python and getting a "json" response, want to add all the loops to a file to read later on excel, or other json reader...

    for x in range(1, 6):
    url = f"https://api.xxx.com.br/ecommerce-web/api/parceiro/meuCadastro/{x}/true"
    response = requests.get(url, headers=headers)
    print(response.json())


    So after this loop I got 5 responses like this

    {'A': 1, 'Name': 'Name01'}
    {'A': 2, 'Name': 'Name02'}
    {'A': 3, 'Name': 'Name03'}
    {'A': 4, 'Name': 'Name04'}
    {'A': 5, 'Name': 'Name05'}


    And i want to do a json file with all that answers, thank you guys! I'm just starting on webscraping.

    Solve this problem add all the answers on json file

    Continue reading...

Compartilhe esta Página