Advertisement
Guest User

Untitled

a guest
Mar 12th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import json
  3. import requests
  4.  
  5. print('Музыка и видео')
  6. response = requests.get("https://www.ozon.ru/api/cms-api.bx/menu/category/child/v1?menuId=1&categoryId=13100&hash=a08c2a31-f125-4678-bec8-11e197dafe0b")
  7. print('Response body: {}'.format(response.text))
  8. data = response.json()
  9.  
  10. for lines1 in data['categories']:
  11.     print(lines1['id'])
  12.  
  13. with open('data.json', 'w', encoding = 'UTF-8') as file:
  14.     json.dump(data, file)
  15.  
  16. # преобразуем словарь в json и записываем в файл
  17. with open('data.txt', 'w', encoding = 'UTF-8') as file:
  18.     json.dump(lines1['id'] + '\n', file, ensure_ascii = False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement