R
R
RD1706D2022-03-11 22:42:39
Python
RD1706D, 2022-03-11 22:42:39

How to parse information from a JS script in Python?

At the moment I am writing a parser to get information about a product from an online store site, using Selenium and BeautifulSoup for this. After loading the page, I load the script file I need (it stores information about the product), and then open it through BS, the question is how to search by JS tags, not HTML, which BS searches for, and if this cannot be done on BS, then Can anyone suggest me libraries that are suitable for this kind of work?

Example script:

{"id":5501988,"name":"Mixer","productId":3535735,"required":false,"logic":"or","typeControl"}

Need to parse id

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2022-03-11
@bacon

Duy google json, where do you even come from.

A
AVKor, 2022-03-12
@AVKor

import json

DOC = '{"id":5501988,"name":"Смеситель","productId":3535735,"required":false,"logic":"or","typeControl":""}'
data = json.loads(DOC)
print(data['id'])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question