T
T
Taya2019-05-29 15:47:09
Python
Taya, 2019-05-29 15:47:09

How to get the data if the div is empty, and the site displays data in this div?

There is a website.
I'm trying to get data from there, from , there is a name, phone number, etc., but when I click to see the page code, there is nothing in this div-e.
Therefore, I can't parse anything.
There is only a big script like

({"cities":{"74858":{"name":"\u0420\u043e\u0441\u0441\u0438\u044f","code":"rossiya","id":"74858","title":"\u041c\u0430\u0433\u0430\u0437\u0438\u043d\u044b LIME \u0432 \u0420\u043e\u0441\u0441\u0438\u0438 | \u041a\u0430\u0440\u0442\u0430","description":"LIME \u2014 \u043c\u0430\u0440\u043a\u0430 \u0431\u0440\u0435\u043d\u0434\u043e\u0432\u043e\u0439 \u0436\u0435\u043d\u0441\u043a\u043e\u0439 \u043e\u0434\u0435\u0436\u0434\u044b \u0438 \u0430\u043a\u0441\u0435\u0441\u0441\u0443\u0430\u0440\u043e\u0432. \u041c\u044b \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043c\u043e\u0434\u043d\u044b\u0435 \u0442\u0435\u043d\u0434\u0435\u043d\u0446\u0438\u0438 \u043f\u043e \u0432\u044b\u0433\u043e\u0434\u043d\u043e\u0439 \u0446\u0435\u043d\u0435. \u041d\u0430\u0439\u0442\u0438 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439 \u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430\u0448\u0435\u0439 \u0441\u0435\u0442\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0432 \u044d\u0442\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435.","keywords":"\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u044b lime \u0440\u043e\u0441\u0441\u0438\u044f \u043a\u0430\u0440\u0442\u0430"

It turns out how to get the data? Is it necessary to somehow get the values ​​\u043e\u0441\u0441\u0438\u044f from under the script tag with regular expressions, and then translate them into a readable form?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2019-05-29
@Taya93

import requests
import json
import re

r = requests.get("https://lime-shop.ru/shops/moskva/")
a = json.loads(re.search("_shops\.init\((.*?)\);", r.text).group(1))

for shop in a['shops']:
    print(shop['caption'])

H
hzzzzl, 2019-05-29
@hzzzzl

I don’t know about python, javascript itself translates unicode characters like \u0420\u043e\u0441\u0441\u0438\u044f into text
in general, if you need to do this only once, then here is the object in the console
https://codepen.io/anon /pen/vwzzmQ?editors=1010

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question