M
M
Michal Palych2020-09-21 00:04:17
Python
Michal Palych, 2020-09-21 00:04:17

How to get the value of the "photo_130" parameter?

Good night everybody! We have a json file, and, as far as I understand, a nested list in this file.
Is it possible to get the value "photo_130"?
So that, for example, on the output "some value"
The json file itself (or rather, an excerpt from it) is given below:

{"count": 33562, 
"items": [{"id": 10266265, "from_id": -12353330, "owner_id": -12353330, "date": 1589042820, 
"marked_as_ads": 0, "post_type": "post", 
"text": "\u0414\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0443\u0440\u043e\u043a \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f.\n\n\u0423\u0447\u0438\u043b\u043a\u0430:", 
"is_pinned": 1, "attachments": [{"type": "video", "video": {"access_key": "****", "can_comment": 0, 
"can_like": 1, "can_repost": 1, "can_subscribe": 1, "can_add_to_faves": 1,
"can_add": 1, "comments": 90, "date": 1589020722, 
"description": "\u0415\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0438\u0434\u043e\u0441\u043e\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0433\u043e\u0432\u043e\u0440\u043e\u0432 \u0442\u0443\u0442: https://vk.com/ссылка_на_паблик", 
"duration": 19, "photo_130": "какое-то значение"...


PS: if necessary, this is the result of vk_api.wall.get

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2020-09-21
@SenqHabr

Something like:

data = '{"count": 33562, "items": [{"id": 10266265, ...'

for item in data['items']:
  for attach in item['attachments']:
    value = attach["photo_130"]
    print (f"{value}")

Iterate over all items and attachments in them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question