Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # SCRAPPING AliExpress
- # Esta página es oro puro: https://codebeautify.org/jsonviewer
- import requests
- import re
- import json
- from bs4 import BeautifulSoup
- req = requests.get('https://es.aliexpress.com/item/4000055758113.html')
- soup = BeautifulSoup(req.text, "html.parser")
- #print (soup)
- tag = soup.find('script', string=re.compile('window.runParams'))
- #print(tag)
- extr = re.search(r'window\.runParams = \{\s+data: (\{[\s\S]+\}\})[\s\S]+\}\;\n', tag.getText())
- conv = json.loads(extr.group(1))
- #print(extr.group(1))
- nombre_producto = conv["pageModule"]["title"] # Descripción del artículo
- vendedor = conv['storeModule']['storeName'] # Nombre del vendedor
- n_categoria = len(conv['crossLinkModule']['breadCrumbPathList']) # Cuántas categorías hay
- categoria = conv['crossLinkModule']['breadCrumbPathList'][n_categoria-1]['name'] # Última categoría
- precio_anterior = conv['skuModule']['skuPriceList'][0]['skuVal']['skuAmount']['value'] # Precio anterior
- precio_actual = float(conv['skuModule']['skuPriceList'][0]['skuVal']['actSkuMultiCurrencyCalPrice']) # Precio actual
- likes = conv['actionModule']['itemWishedCount'] # Cuántos 'Me Gusta' tiene el artículo
- stock = conv['actionModule']['totalAvailQuantity'] # Cuántas unidades hay disponibles
- url_imagen = conv['imageModule']['imagePathList'][0] # URL de la imagen
- valoracion = float(conv['titleModule']['feedbackRating']['averageStar']) # Valoración de los clientes
- print ("")
- print ("NOMBRE PRODUCTO...: " + nombre_producto)
- print ("")
- print ("VENDEDOR..........: " + vendedor)
- print ("")
- print ("CATEGORIA.........: " + categoria)
- print ("")
- print ("PRECIO ANTERIOR...: " + str(precio_anterior))
- print ("")
- print ("PRECIO ACTUAL.....: " + str(precio_actual))
- print ("")
- print ("LIKES.............: " + str(likes))
- print ("")
- print ("STOCK.............: " + str(stock))
- print ("")
- print ("URL IMAGEN........: " + url_imagen)
- print ("")
- if valoracion != 0:
- print ("VALORACIÓN........: " + str(valoracion) + " de 5")
- print ("")
Add Comment
Please, Sign In to add comment