D
D
del4pp2020-06-03 21:56:06
Python
del4pp, 2020-06-03 21:56:06

Save as html, via python, how?

Hello uv. connoisseurs.
I save the page through the browser as html, saves as it should, links, tags, etc.
I save through Python - in the js file, the code instead of links.
How to save through python as well as through the right browser button without selenium?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-06-03
@del4pp

Your products are displayed after JS rendering. Regular requests to the site (via requests, etc.) do not execute JS code. You can see how requests sees the page through CTRL + U. If you look through RightClick -> Inspect Element, then you see the already rendered code.
If you press F12 -> Network, refresh the page and open XHR requests, you will see that all products are searched through the request

https://brain.com.ua/search/1187/?Search=10750&Offset=0

and
https://brain.com.ua/search/142/?Search=10750&Offset=0

Where 1187 and 142 are categories as far as I understand and 10750 is your search term. Offset is understandable.
So you have two options:
  1. Make requests according to the example I sent above and parse their products from the response
  2. Open the desired page through selenium and save the code. I think in selenium there is such an option

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question