Попытка поднять розничную цену azure

#python #azure #api #azure-devops

#питон #лазурь #API #azure-devops

Вопрос:

Я пытаюсь получить розничные цены Azure по этой ссылке, но она выдает мне эту ошибку.Пожалуйста, объясните мне, что делать.

Я не хочу применять какой-либо фильтр в ссылке.

 import requests import json import pandas as pd import os from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry # Call the Azure Retail Prices API response = requests.get("https://prices.azure.com/api/retail/prices") #response = http.request("GET", "https://example.com/", retries=Retry(10)) # Set your file location and filename to save your json and excel file #filelocation = r'Folderpath' filename = 'azureretailprices_vm_scus'  # Create an array to store price list priceitems= [] #Add the retail prices returned in the API response to a list for i in response.json()['Items']:  priceitems.append(i)   print(response.json()["NextPageLink"])  # Retrieve price list from all available pages until there is no 'NextPageLink' available to retrieve prices # Retrieve price list from all available pages until there is a 'NextPageLink' available to retrieve prices while response.json()["NextPageLink"] != None:   for i in response.json()['Items']:  priceitems.append(i)   response = requests.get(response.json()["NextPageLink"])  print(response.json()["NextPageLink"])  # Retrieve price list from the last page when there is no "NextPageLink" available to retrieve prices if response.json()["NextPageLink"] == None:  for i in response.json()['Items']:  priceitems.append(i)   # Write the price list to a json file with open(os.path.join('folder',filename)   '.json', 'w') as f:  json.dump(priceitems, f) # Open the price list json file and load into a variable with open(os.path.join('folder',filename)   '.json', encoding='utf-8') as f:  raw = json.loads(f.read()) # Convert the price list into a data frame df = pd.json_normalize(raw) # Save the data frame as an excel file df.to_excel(os.path.join('folder',filename)   '.xlsx', sheet_name='RetailPrices', index=False)  

Снимок экрана с ошибкой:

введите описание изображения здесь

Ответ №1:

введите описание изображения здесь

Ошибка связана с версией pyOpenSSL So, попробуйте изменить версию на последнюю, т. е.,

  • удалите предыдущую версию pyOpenSSL и
  • установите последнюю версию pyOpenSSL-21.2.0 (последнюю версию).