Q
Q
quintbrut2020-04-19 20:10:23
Python
quintbrut, 2020-04-19 20:10:23

How to get data from json using BS4?

You need to find data from the 1.json file, the code of which looks like

So
{"status":1,"data":{"enemy":{"name":"Moon outsider","type":"strength","power":"middle","stats":{"health":184,"maxHealth":184,"strength":40,"dexterity":30,"critical":21}},"player":{"stats":{"health":211,"maxHealth":211,"strength":42,"dexterity":32,"critical":38}},"changeEnemy":{"isAvailable":true,"price":"<em class='nowrap'><img align=\"absmiddle\" class=\"inline-icon\" border=\"0\" src=\"https:\/\/example.com\/i\/icons\/lave.png\" alt=\"\u043b\u0430\u0432\u044d\" \/> <span id=\"harvestSum\">100<\/span><\/em>"},"newRing":"","weapon":false}}
. and write data to separate variables. for example, find name and write them into a variable of the same name.
For example name = Moon outside
or strength1 = 40
strength2 = 42.

The problem is how to search in json? if it is provided in the browser
So
5e9c85e65cffa886113697.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2020-04-19
@bacon

know json.loads

S
Sergey Ilyin, 2020-04-19
@sunsexsurf

You need to do a few things:
1/ select Network in developer mode
2/ reload the page
3/ see what get requests go
4/ try to imitate such a get request
5/ and parse the already received html code with soup
if anything - write.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question