P
P
Pol1na2021-04-24 12:45:06
Parsing
Pol1na, 2021-04-24 12:45:06

How to implement parsing of variable products?

I'm learning parsing. I ran into a problem when parsing variable products, for example, as in the picture
6083e863a8a43211213087.png
. When you select certain characteristics, the price of the product changes.
How to solve such a problem and what is the best way to upload data, for example, to .csv?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-04-24
@Pol1na

Either selenium, or just like in normal parsing, it's no different. We also open the page code and look for the necessary data.

import requests
import json
import re

r = requests.get('https://aliexpress.ru/item/4000985692469.html')

script = json.loads(re.search(r'{"actionModule.+}}', r.text).group())
goods = script['skuModule']['skuPriceList']

for good in goods:

    name = good['skuAttr'].split('#')[-1]
    price = good['skuVal']['skuActivityAmount']['formatedAmount']

    print(name, price)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question