Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- """
- https://woocommerce.github.io/woocommerce-rest-api-docs/
- p2020-dicionario-woo-sku.py
- ---------------------------
- copyright GPL V2 ou posterior
- .......................................
- criado por gsavix em 15-julho-2020 copyright GPL V2 ou posterior
- atualizado em 22-nov-2020
- atualizado em 27-mar-2021
- atualizado em 28-set-2021
- atualizado em 09-out-2021 dicionario classificado chave
- atualizado em 25-mai-2023 dicionary seo html split mesma linha
- .......................................
- ==============================================
- leitura da api-woocommerce gflo gera lista com
- dicionario de campos existentes no woocommerce
- para os produtos sku-root e variacoes
- ==============================================
- ##############################################
- idroot,skuroot,idvariation,skuvariation
- [0] [1] [2]n [3]n
- campos [2] e [3] podem ter n ocorrencias
- ##############################################
- """
- #
- # diversos importas para funcionalidades
- #
- import csv
- import locale
- import codecs
- import json
- import time
- from woocommerce import API
- from lxml import html
- #
- #
- #
- axlie1=list() # idroot e skuroot
- axfne1 = './arq/axsaiverz.csv' # arquivo de entrada asc. ref.
- axfns1 = './arq/axwoodict' # arquivo de saida com dicionario woo
- #
- #
- #
- locale.setlocale(locale.LC_ALL, '') # estabelece locale
- axencoding = locale.getpreferredencoding()
- axlocalenc = axencoding.format() # cp1252 utf-8 etc
- wcapi = API(
- url="url-your-service-base-api-woocommerce", # Your store URL
- consumer_key="ck_change-for-your-consumer-key", # iduser
- consumer_secret="cs_change-for-your-consumer-secret", # token
- wp_api=True,timeout=25, # Enable the WP REST API integration
- version="wc/v3" # WooCommerce WP REST API version
- )
- #
- #
- #
- axprefixdt = time.strftime("%Y%m%dT%H%M", time.localtime())
- locale.setlocale(locale.LC_ALL, '') # locale LC_ALL para pt-br
- print('*** p2828-dicionario-woo-sku-variacoes BOJ ***', axprefixdt)
- axef1 = codecs.open(axfne1,'r', encoding='utf8', errors='surrogateescape')
- axsf1 = codecs.open(axfns1+'-'+axprefixdt+'.csv','w', encoding='utf8', errors='surrogateescape')
- #
- # grava header csv ('skuroot','skuchild','conteudo')
- #
- axsf1.write('a1root | b1chave | c1chave | d1dados' + '\n') # tres colunas skuroot, skuvar, chave, dados
- #
- axlie1 = csv.reader(axef1, delimiter=';')
- for axlin in axlie1:
- axp = wcapi.get("products/" + str(axlin[0]).lstrip('0') + "/").json()
- print(axlin[0], ' ', axlin[1].ljust(20,' ')) # quem eh skuroot
- axlista = list() # lista para classificacao chave, dados
- for axk, axv in axp.items():
- if axk in ['short_description','description','price_html','yoast_head']:
- axv = axv.replace('\n',' <tra></tra> ').replace('<br>',' ').replace('</br>',' ') # espacos
- if axv != '':
- axht = html.fromstring(axv)
- axv = axht.text_content()
- axv = '"' + axv + '"'
- axlista.append([axk, str(axv)]) # chave e valores vao para lista
- axlistas = list() # lista ordenada vazia
- axlistas = sorted(axlista, key=lambda axkd: axkd[0]) # ordena por chave
- ixs = 0
- for ixs in range(len(axlistas)): # recupera lista ordenada
- axrro = str(axlin[1]) + '|' + 'skuroot|' + str(axlistas[ixs][0]).ljust(25,'.')
- axrro = axrro + '>|' + str(axlistas[ixs][1]) # dicionario skuroot key,value
- axsf1.write(axrro + '\n')
- for ixv in range(2,len(axlin),2): # todas skuvar deste skuroot
- axqvar = "products/" + str(axlin[0]).lstrip('0') + "/variations/" + str(axlin[ixv]).lstrip('0') + "/"
- axppv = wcapi.get(axqvar).json()
- axlista = list() # lista variacoes classif. chave, dados
- for axpvk, axpvv in axppv.items():
- axlista.append([axpvk, str(axpvv)]) # skuvar chave e dados
- axlistas = list() # init axlistas sorted
- axlistas = sorted(axlista, key=lambda axkd: axkd[0]) # ordena por chave
- ixs = 0
- for ixs in range(len(axlistas)): # recupera lista ordenada
- axrva = str(axlin[1]) + '|' + axlin[ixv+1] + '|' + str(axlistas[ixs][0]).ljust(25,'.')
- axrva = axrva + '>|' + str(axlistas[ixs][1]) # dicionario skuvar key,value
- axsf1.write(axrva + '\n')
- print(axlin[0], ' ', axlin[1].ljust(20,' '), ' ', axlin[ixv+1].ljust(20, ' ')) # idroot, skuroot e skuvar
- axef1.close() # fecha entrada 1
- axsf1.close() # fecha saida 1
- axprefixdt = time.strftime("%Y%m%dT%H%M", time.localtime())
- print('*** p2828-dicionario-woo-sku-variacoes EOJ ***', axprefixdt)
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=wtyxegyhyd
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment