Skip to content

Commit b18655a

Browse files
authored
Macro em python para o Mercado Livre
1 parent abd95d7 commit b18655a

File tree

1 file changed

+280
-0
lines changed

1 file changed

+280
-0
lines changed

macro.py

Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
from selenium import webdriver
2+
from selenium.webdriver.common.by import By
3+
import time
4+
5+
# ----- CONFIGURAÇÃO -----
6+
# Lista de SKUs a serem testados
7+
sku_list = [
8+
"377857043C",
9+
"377857043C033",
10+
"377857043C2P2",
11+
"377857043C71N",
12+
"377857043C999",
13+
"377857043C9V5",
14+
"377857043CU71",
15+
"337857043C",
16+
"337857043C033",
17+
"337857043C2P2",
18+
"337857043C71N",
19+
"337857043C999",
20+
"337857043C9V5",
21+
"337857043CU71",
22+
"377959565",
23+
"377959565999",
24+
"377959565A",
25+
"377959565A999",
26+
"3779595651NN",
27+
"3279595651",
28+
"32795956511NN",
29+
"3279595651999",
30+
"377807657",
31+
"377807657999",
32+
"377807657773",
33+
"377807655",
34+
"377807655999",
35+
"377807655773",
36+
"3778076552GV",
37+
"3778076552GVPVC",
38+
"377807655B",
39+
"377807655B999",
40+
"377807655B773",
41+
"377807658",
42+
"377807658773",
43+
"377807658999",
44+
"373837181A",
45+
"373837181",
46+
"373837181A999",
47+
"373837181C05",
48+
"377853687DA",
49+
"377827935",
50+
"377827935A",
51+
"377863293EVNQ",
52+
"377711141DXDB",
53+
"377853687DNI3K",
54+
"3778536872RA",
55+
"377853685E",
56+
"308853555A",
57+
"308853555ALE",
58+
"308853555",
59+
"308853555A773",
60+
"308853556A",
61+
"308853556",
62+
"308853556ALE",
63+
"308853556A773",
64+
"3088294521",
65+
"308829452",
66+
"3088294511",
67+
"308829451",
68+
"3088294531",
69+
"308829453",
70+
"376945096A",
71+
"376945095A",
72+
"376945112A",
73+
"376945111A",
74+
"377853193B",
75+
"APR898700K",
76+
"APR898700K71N",
77+
"APR898700K1GR",
78+
"APR898700K1AK",
79+
"APR898700K999",
80+
"APR898700AN",
81+
"APR898700AN1NN",
82+
"APR898700AM",
83+
"APR898700AM1NN",
84+
"APR898700AH",
85+
"APR898700AH1GR",
86+
"APR898700AH71N",
87+
"APR898700AH999",
88+
"APR061220",
89+
"APR06122071N",
90+
"377837181A",
91+
"377837181",
92+
"377837181A999",
93+
"377837181C05",
94+
"376853687F",
95+
"5x7853687B",
96+
"377857077F",
97+
"377857077F1NN",
98+
"377857077F999",
99+
"3B0853601FDY",
100+
"377853601",
101+
"5X0959537",
102+
"5X0419091AB",
103+
"5X0419091AB1NN",
104+
"5x6945112d",
105+
"5x6945111d",
106+
"377945097B",
107+
"377945097B1KE",
108+
"377837181C",
109+
"377857961A05",
110+
"5X6945096D",
111+
"5X6945095E",
112+
"377807221AE",
113+
"377807421E",
114+
"5x03807421A",
115+
"5X0711118AVNQ",
116+
"5X0711118DVN",
117+
"5X0711118UNQ",
118+
"377863293EFGK",
119+
"542959565",
120+
"377919033GD",
121+
"377919033AG",
122+
"377919033HB",
123+
"377919033KG",
124+
"377419669C",
125+
"5X0880201A",
126+
"3771212251RA",
127+
"5X0419091",
128+
"5X0419091T",
129+
"5X0419091T1NN",
130+
"5X04190911NN",
131+
"5X0419091AP",
132+
"5X0419091AP1NN",
133+
"5X0419091AN",
134+
"5X0419091AN1NN",
135+
"5X0419091AG",
136+
"5X0419091AG1NN",
137+
"5X0419091APTHW",
138+
"5X0419669A",
139+
"5X0419669A1NN",
140+
"377422371D",
141+
"305422375A",
142+
"5X9945112C",
143+
"5X9945112A",
144+
"373857043A",
145+
"373857043A999",
146+
"373857043A2BV",
147+
"379941531L",
148+
"5W0863835A",
149+
"5W0863835",
150+
"377863833P",
151+
"377863833",
152+
"377863833P",
153+
"377863353L",
154+
"377863353H",
155+
"373941531JO",
156+
"373941531KO",
157+
"373941531LO",
158+
"377863293KXG4",
159+
"93218414",
160+
"93202323",
161+
"93231183",
162+
"90304341",
163+
"90327307",
164+
"90327308",
165+
"90339944",
166+
"90339943",
167+
"90339942",
168+
"90276297",
169+
"90376182",
170+
"90377395",
171+
"93202324",
172+
"93202071",
173+
"93202071ALT",
174+
"93256728",
175+
"90376131",
176+
"93223669",
177+
"90376130",
178+
"93223670",
179+
"93224657",
180+
"90369814",
181+
"90297557",
182+
"3495475",
183+
"90427888",
184+
"93239756",
185+
"90327276",
186+
"90339904",
187+
"90327275",
188+
"90339903",
189+
"90327311",
190+
"93204766",
191+
"90376182",
192+
"93251376",
193+
"90214669",
194+
"90439331",
195+
"93226705",
196+
"93226706",
197+
"93256727",
198+
"90277985",
199+
"93271755",
200+
"90376081",
201+
"93256727",
202+
"93240343",
203+
"90378087",
204+
"93276225",
205+
"93229665",
206+
"305120102",
207+
"305120101",
208+
"90327270",
209+
"90327271",
210+
"93218221",
211+
"93210993",
212+
"93223361",
213+
"93210999",
214+
"93223363",
215+
"93223359",
216+
"93223357",
217+
"93223364",
218+
"90327271",
219+
"93213600",
220+
"90379368",
221+
"V1G214900",
222+
"V3G215005",
223+
"V1G217700",
224+
"90271904",
225+
"90271903",
226+
"94654223",
227+
"90443382",
228+
"90355761",
229+
"90511966",
230+
"93234187",
231+
"90347026",
232+
"90347027",
233+
"90444203",
234+
"90444204",
235+
"93228426",
236+
"93248956",
237+
"90332355",
238+
"90332356",
239+
"90434155",
240+
"93228757",
241+
"90434156",
242+
"93228756",
243+
"90407004"
244+
# ... adicione quantos SKUs quiser
245+
]
246+
247+
# Inicializa o driver (Chrome). Ajuste se for usar Firefox ou outro.
248+
driver = webdriver.Chrome()
249+
250+
try:
251+
for sku in sku_list:
252+
url = f"https://lista.mercadolivre.com.br/{sku}"
253+
print(f"Abrindo SKU {sku}: {url}")
254+
driver.get(url)
255+
time.sleep(2) # espera a página carregar
256+
257+
# Tenta encontrar a mensagem de "sem anúncios"
258+
try:
259+
aviso = driver.find_element(
260+
By.CSS_SELECTOR,
261+
"h3.ui-search-rescue__title"
262+
)
263+
if "Não há anúncios que correspondam à sua busca" in aviso.text:
264+
print(f" → SKU {sku}: sem anúncios. Pulando.\n")
265+
continue # pula para o próximo SKU
266+
except:
267+
# Se não encontrar o elemento, segue adiante
268+
pass
269+
270+
# Se chegou aqui, há pelo menos um anúncio
271+
print(f" → SKU {sku}: anúncios encontrados! Aguardando 4 s e scroll...")
272+
time.sleep(4)
273+
274+
# Executa scroll de 800px vertical
275+
driver.execute_script("window.scrollBy(0, 800);")
276+
print(" → Scroll realizado. Seguindo para o próximo.\n")
277+
278+
finally:
279+
driver.quit()
280+
print("Concluído. Navegador fechado.")

0 commit comments

Comments
 (0)