gsavix

howto create woocommerce product dictionary

Feb 21st, 2026
86
0
Never
9
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.12 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. https://woocommerce.github.io/woocommerce-rest-api-docs/
  5.  
  6. p2020-dicionario-woo-sku.py
  7. ---------------------------
  8. copyright GPL V2 ou posterior
  9. .......................................
  10. criado por gsavix em 15-julho-2020 copyright GPL V2 ou posterior
  11. atualizado em 22-nov-2020
  12. atualizado em 27-mar-2021
  13. atualizado em 28-set-2021
  14. atualizado em 09-out-2021 dicionario classificado chave
  15. atualizado em 25-mai-2023 dicionary seo html split mesma linha
  16. .......................................
  17.  
  18. ==============================================
  19. leitura da api-woocommerce gflo gera lista com
  20. dicionario de campos existentes no woocommerce
  21. para os produtos sku-root e variacoes
  22. ==============================================
  23.  
  24. ##############################################
  25. idroot,skuroot,idvariation,skuvariation
  26. [0]    [1]     [2]n        [3]n
  27. campos [2] e [3] podem ter n ocorrencias
  28. ##############################################
  29.  
  30. """
  31. #
  32. # diversos importas para funcionalidades
  33. #
  34. import  csv
  35. import  locale
  36. import  codecs
  37. import  json
  38. import  time
  39. from    woocommerce import API
  40. from    lxml import  html
  41. #
  42. #
  43. #
  44. axlie1=list()                                               # idroot e skuroot
  45. axfne1 = './arq/axsaiverz.csv'                            # arquivo de entrada asc. ref.  
  46. axfns1 = './arq/axwoodict'                                  # arquivo de saida com dicionario woo
  47. #
  48. #
  49. #
  50. locale.setlocale(locale.LC_ALL, '')                         # estabelece locale
  51. axencoding = locale.getpreferredencoding()
  52. axlocalenc = axencoding.format()                            # cp1252 utf-8 etc
  53. wcapi = API(
  54.     url="url-your-service-base-api-woocommerce", # Your store URL
  55.     consumer_key="ck_change-for-your-consumer-key", # iduser
  56.     consumer_secret="cs_change-for-your-consumer-secret", # token
  57.     wp_api=True,timeout=25, # Enable the WP REST API integration
  58.     version="wc/v3" # WooCommerce WP REST API version
  59. )
  60. #
  61. #
  62. #
  63. axprefixdt = time.strftime("%Y%m%dT%H%M", time.localtime())
  64. locale.setlocale(locale.LC_ALL, '')         # locale LC_ALL para pt-br
  65. print('*** p2828-dicionario-woo-sku-variacoes BOJ ***', axprefixdt)
  66. axef1  = codecs.open(axfne1,'r', encoding='utf8', errors='surrogateescape')
  67. axsf1  = codecs.open(axfns1+'-'+axprefixdt+'.csv','w', encoding='utf8', errors='surrogateescape')
  68. #
  69. # grava header csv ('skuroot','skuchild','conteudo')
  70. #
  71. axsf1.write('a1root | b1chave | c1chave | d1dados' + '\n')            # tres colunas skuroot, skuvar, chave, dados
  72. #
  73. axlie1 = csv.reader(axef1, delimiter=';')
  74. for axlin in axlie1:
  75.     axp = wcapi.get("products/" + str(axlin[0]).lstrip('0') + "/").json()
  76.     print(axlin[0], ' ', axlin[1].ljust(20,' '))            # quem eh skuroot
  77.     axlista = list()                                        # lista para classificacao chave, dados
  78.     for axk, axv in axp.items():
  79.         if axk in ['short_description','description','price_html','yoast_head']:
  80.             axv = axv.replace('\n',' <tra></tra> ').replace('<br>',' ').replace('</br>',' ') # espacos
  81.             if axv != '':
  82.                 axht = html.fromstring(axv)
  83.                 axv  = axht.text_content()  
  84.                 axv  = '"' + axv + '"'
  85.         axlista.append([axk, str(axv)])                     # chave e valores vao para lista
  86.     axlistas = list()                                       # lista ordenada vazia
  87.     axlistas = sorted(axlista, key=lambda axkd: axkd[0])    # ordena por chave
  88.     ixs      = 0
  89.     for ixs in range(len(axlistas)):                        # recupera lista ordenada
  90.         axrro = str(axlin[1]) + '|' + 'skuroot|' + str(axlistas[ixs][0]).ljust(25,'.')
  91.         axrro = axrro + '>|' + str(axlistas[ixs][1])        # dicionario skuroot key,value
  92.         axsf1.write(axrro + '\n')
  93.     for ixv in range(2,len(axlin),2):                           # todas skuvar deste skuroot
  94.         axqvar  = "products/" + str(axlin[0]).lstrip('0') + "/variations/" + str(axlin[ixv]).lstrip('0') + "/"
  95.         axppv = wcapi.get(axqvar).json()
  96.         axlista = list()                                        # lista variacoes classif. chave, dados        
  97.         for axpvk, axpvv in axppv.items():
  98.             axlista.append([axpvk, str(axpvv)])                 # skuvar chave e dados
  99.         axlistas = list()                                       # init axlistas sorted
  100.         axlistas = sorted(axlista, key=lambda axkd: axkd[0])    # ordena por chave
  101.         ixs      = 0
  102.         for ixs in range(len(axlistas)):                        # recupera lista ordenada
  103.             axrva = str(axlin[1]) + '|' + axlin[ixv+1] + '|' +  str(axlistas[ixs][0]).ljust(25,'.')
  104.             axrva = axrva + '>|' + str(axlistas[ixs][1])        # dicionario skuvar key,value
  105.             axsf1.write(axrva + '\n')
  106.         print(axlin[0], ' ', axlin[1].ljust(20,' '), ' ', axlin[ixv+1].ljust(20, ' '))   # idroot, skuroot e skuvar
  107. axef1.close()                               # fecha entrada 1
  108. axsf1.close()                               # fecha saida 1
  109. axprefixdt = time.strftime("%Y%m%dT%H%M", time.localtime())
  110. print('*** p2828-dicionario-woo-sku-variacoes EOJ ***', axprefixdt)
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Pyrregmi
    23 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. 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.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • Exowolig
    1 day
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=wtyxegyhyd
    4.  
    5. 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.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment