Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import codecs
- import openpyxl
- import time
- import locale
- ##
- ## p24333-mlivreqv.py planilha anuncios mercado livre
- ## copyright gsavix 2018-2026 terms gpl V2 or later
- axsepsku = 'v'
- axprefixdt = time.strftime("%Y%m%dT%H%M%S", time.localtime())
- print("#===============================================#")
- print("### inicio data-hora.: ", axprefixdt)
- print("#===============================================#")
- locale.setlocale(locale.LC_ALL,'')
- axencoding = locale.getpreferredencoding()
- ##
- ## carrega planilha com anuncios ativos mercado livre do dia
- ##
- workbook = openpyxl.load_workbook('./arq/axfanuncios.xlsx',keep_links=True,rich_text=True) # faz a leitura
- worksheet = workbook['Anúncios'] # utiliza a pasta anuncios
- total_rows = worksheet.max_row
- total_cols = worksheet.max_column
- axabc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- ## # booleanos
- axatual = False # indicador atualizacao
- axanunr = False #
- axtntem = False # tem nos anuncios
- #
- # tabela de quantidade e valor para mercado livre tabela 3
- #
- axfne2 = './arq/vp1748ex-mlivreqv.csv'
- axef2 = codecs.open(axfne2,'r', encoding=axencoding, errors='surrogateescape')
- axlie2 = axef2.readlines()
- axef2.close()
- #
- #
- #
- axtbprd = dict() # dicionario produto skuvar, qtd, vlrvarejo
- axtbanu = dict() # dicionario id anuncio root, vlr # para atualizar o valor do skuroot
- # # apenas se for diferente
- #
- # # constroi dicionario produtos,qtd,vlr
- for ix22 in range(len(axlie2)): # scan por todos produtos mlivreqv
- axmp=axlie2[ix22].replace('\n','').replace('\r','').split(';')
- axmpqt=axmp[3]
- if axmpqt in ['',' ','None']: # qtd vazio ou nulo troca para 0
- axmpqt = '0'
- #
- # importante planilha do mlivre utiliza . para decimais portanto manteremos edicao sistema estoque
- #
- axmpvlrv = axmp[4][:-3].replace('.','') # preco base despreza decimais vlr varejo
- #
- # compoe lista qtd e valor para atualizar qtd no skuvar e o valor no skuroot do mlivre
- #
- axliqtvl = list() # inicializa lista qtd,vlr
- axliqtvl.append(str(axmpqt)) # qtd em estoque no estoque
- axliqtvl.append(str(axmpvlrv)) # valor varejo no estoque tabela 3 mlivre
- axtbprd[axmp[0]+axsepsku+axmp[1]+axsepsku+axmp[2]]=axliqtvl # skuvar + lista qtd,valor varejo
- #print(axtbprd.keys())
- #print('-------------------------')
- #print(axtbprd.values())
- #
- #
- #
- #
- #
- axprefixdt = time.strftime("%Y%m%d-%H%M", time.localtime())
- print("### data-hora.: ", axprefixdt, " ###" )
- print("### fase-11.: entenda as colunas da planilha mlivre. cabecalhos ativos")
- for ixcol in range(total_cols): # vamos da coluna a ate as colunas existentes
- print(str(ixcol+1).ljust(2,' ') + " | " + axabc[ixcol] + " | ",
- worksheet[1][ixcol].value.ljust(30,'.'),
- " | ",) # mantem mesma linha
- #
- #
- #
- print("### fase-21.: identifica e atualiza quantidade variacoes SKU detalhe.")
- ####
- ####
- ####
- for ixlin in range(7, total_rows + 1): ### vamos ver skuroot qtd total e valores
- if str(worksheet[ixlin][1].value) in ['',' ', 'None']: ### quando vazio ou em branco
- print("#===============================================#")
- print(str(ixlin).ljust(4,' ') + " |",
- str(worksheet[ixlin][0].value).ljust(15,' ') + " |",
- str(worksheet[ixlin][7].value).replace('.0','.00').rjust(15,' ') + " |",
- str(worksheet[ixlin][8].value).replace('.0','.00').rjust(25,' ') + " |",
- str(worksheet[ixlin][5].value).rjust(6,' ') + " |",
- str(worksheet[ixlin][16].value).ljust(25,' ') + " |",
- str(worksheet[ixlin][3].value).ljust(60,' ')[:60]
- )
- axanunr = False # inicializa indicador anuncio root
- else:
- ### vamos ver sku-detalhes qtd
- axskuvar=str(worksheet[ixlin][2].value) # skuvar mlivre
- axtntem = False
- axatual = False
- axmsgat = ' '
- if axskuvar not in axtbprd.keys():
- axmsg = axskuvar.ljust(15, ' ') + ' *** ko '
- else:
- axmsg = axskuvar.ljust(15, ' ') + ' *** OK ' + str(axtbprd[axskuvar][0]) # se achou mostra qtd
- axtntem = True
- ##
- ## aqui outro conceito implementado em novembro-2024
- ## como estamos implementando atualizacao diretamente do vp1748ex tabela 3
- ## independente da mudanca de quantidade o valor devera ser atualizado para
- ## refletir as politicas de lista de preco estabelecidas na tabela 3 verup
- ##
- ## if str(worksheet[ixlin][5].value) != str(axtbprd[axskuvar][0]+'.0'):
- if not axatual:
- axatual = True
- axpx = " qtd " + str(axtbprd[axskuvar][0]+'.0') + " valor " + str(axtbprd[axskuvar][1]+'.00')
- axmsgat = " *** atualizar " + axpx + " ***"
- axfmtm = axmsg.ljust(25,' ')
- print(str(ixlin).ljust(4,' ') + " |",
- str(worksheet[ixlin][0].value).ljust(15,' ') + " |",
- str(worksheet[ixlin][1].value).ljust(15,' ') + " |",
- axfmtm + " |",
- str(worksheet[ixlin][5].value).replace('.0','').rjust(6,' ') + " |",
- str(worksheet[ixlin][4].value).ljust(25,' ') + " |" + axmsgat
- )
- if axatual: # atualiza o anuncio root
- ### # e qtd da variacao
- ### 8 | H | MARKETPLACE_PRICE | ATENCAO
- ### 9 | I | MSHOPS_PRICE | ATENCAO
- worksheet.cell(row=ixlin,column=6,value=axtbprd[axskuvar][0]) # quantidade coluna F=6
- ## aqui conceito implicito eh que todas as variacoes tenham o mesmo preco.
- ## ate 2023 isso nao era uma realidade nos anuncios gf. agora a politica de preco mudou
- ## por isso so faz a carga uma unica vez para cada skuroot independente de qual variacao for
- if not axanunr: # se nao carregou id root desse anuncio
- axanunr = True
- #
- # carga id anuncio root, vlr
- #
- axtbanu[str(worksheet[ixlin][0].value)]=axtbprd[axskuvar][1] # carrega o valor para esse anuncio root
- #
- # atualizar apenas os valores nos anuncios root so onde mudou estoque e se mudou valor
- #
- #
- axprefixdt = time.strftime("%Y%m%d-%H%M", time.localtime())
- print("### data-hora.: ", axprefixdt, " ###" )
- print("#================================================#")
- print("### #")
- print("### fase-31.: modificar valores dos anuncios sku #")
- print("### #")
- print("#================================================#")
- # ### a partir linha 7 da planilha do mlivre
- for ixlinr in range(7, total_rows + 1): ### vamos ver skuroot qtd total e valores
- if str(worksheet[ixlinr][1].value) in ['',' ', 'None']: ### quando vazio ou em branco
- if str(worksheet[ixlinr][0].value) in axtbanu.keys(): ### tem anuncio raiz com para modificar
- ### #################################################################################
- ### # #
- ### # atencao a mudanca de conceito #
- ### # sempre atualizamos todas as quantidades e valores do anuncio # atencao comentario #%%%%161
- ### # independente de ter havido modificacao ou nao #
- ### # aqui o conceito não é sincronizar os anuncios com tabela de precos vp1748ex 3 #
- ### #################################################################################
- #%%%% if str(worksheet[ixlinr][7].value).replace('.0','.00') != axtbanu[str(worksheet[ixlinr][0].value).replace('.0','.00')]:
- axqualsku = '' ## inicializa sku raiz verup, site
- axanu = str(worksheet[ixlinr+1][0].value) ## verifica proxima linha anuncio variacao sku raiz verup
- axqsku = str(worksheet[ixlinr+1][2].value).split('v') ## verifica proxima variacao se tem sku
- if axanu == str(worksheet[ixlinr][0].value) and len(axqsku) > 0:
- axqualsku = axqsku[0] ## compoe qual o produto sku raiz
- print(str(ixlinr).rjust(4, ' '), " | ",
- str(worksheet[ixlinr][0].value).ljust(15, ' '), "|",
- " *** encontrou SKUROOT GF" + axqualsku + " para atualizar valor de ",
- str((worksheet[ixlinr][7].value)).replace('.0','.00'),
- " valor para ",
- axtbanu[str(worksheet[ixlinr][0].value).replace('.0','.00')], " ***")
- ### 8 | H | MARKETPLACE_PRICE | ATENCAO
- ### 9 | I | MSHOPS_PRICE | ATENCAO
- worksheet.cell(row=ixlinr,column=8,value=axtbanu[str(worksheet[ixlinr][0].value)]) # vlr mlivre col 8
- worksheet.cell(row=ixlinr,column=9,value=axtbanu[str(worksheet[ixlinr][0].value)]) # vlr mshop col 9
- #
- #
- #
- #
- print("************************************************")
- print("# conferir a lista de anuncios sincronizados #")
- print("************************************************")
- print(axtbanu.keys())
- print("#=================================================#")
- print("# #")
- print("# fase-41.: grava nova planilha com sufixo upload #")
- print("# axfanuncios_upload.xlsx #")
- print("#=================================================#")
- workbook.save('./arq/axfanuncios_upload.xlsx')
- axprefixdt = time.strftime("%Y%m%d-%H%M", time.localtime())
- print("### data-hora.: ", axprefixdt, " ###" )
- print("#=================================================#")
- print("### p24333-mlivreqv.py final de processamento #")
- #-eof-python
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=gfgxxmuyws
- 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