-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
72 lines (62 loc) · 2.15 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Passo a passo do projeto
# Passo 1: Entrar no sistema da empresa
# https://dlp.hashtagtreinamentos.com/python/intensivao/login
import pyautogui
import time
# pyautogui.write -> escrever um texto
# pyautogui.press -> apertar 1 tecla
# pyautogui.click -> clicar em algum lugar da tela
# pyautogui.hotkey -> combinação de teclas
pyautogui.PAUSE = 0.3
# abrir o navegador (chrome)
pyautogui.press("win")
pyautogui.write("chrome")
pyautogui.press("enter")
# entrar no link
pyautogui.write("https://dlp.hashtagtreinamentos.com/python/intensivao/login")
pyautogui.press("enter")
time.sleep(3)
# Passo 2: Fazer login
# selecionar o campo de email
pyautogui.click(x=530, y=367)
# escrever o seu email
pyautogui.write("pythonimpressionador@gmail.com")
pyautogui.press("tab") # passando pro próximo campo
pyautogui.write("sua senha")
pyautogui.press("tab")
pyautogui.press("enter")
# pyautogui.click(x=670, y=596) # clique no botao de login
time.sleep(3)
# Passo 3: Importar a base de produtos pra cadastrar
import pandas as pd
tabela = pd.read_csv("produtos.csv")
print(tabela)
# Passo 4: Cadastrar um produto
for linha in tabela.index:
# clicar no campo de código
pyautogui.click(x=542, y=248)
# pegar da tabela o valor do campo que a gente quer preencher
codigo = tabela.loc[linha, "codigo"]
# preencher o campo
pyautogui.write(str(codigo))
# passar para o proximo campo
pyautogui.press("tab")
# preencher o campo
pyautogui.write(str(tabela.loc[linha, "marca"]))
pyautogui.press("tab")
pyautogui.write(str(tabela.loc[linha, "tipo"]))
pyautogui.press("tab")
pyautogui.write(str(tabela.loc[linha, "categoria"]))
pyautogui.press("tab")
pyautogui.write(str(tabela.loc[linha, "preco_unitario"]))
pyautogui.press("tab")
pyautogui.write(str(tabela.loc[linha, "custo"]))
pyautogui.press("tab")
obs = tabela.loc[linha, "obs"]
if not pd.isna(obs):
pyautogui.write(str(tabela.loc[linha, "obs"]))
pyautogui.press("tab")
pyautogui.press("enter") # cadastra o produto (botao enviar)
# dar scroll de tudo pra cima
pyautogui.scroll(5000)
# Passo 5: Repetir o processo de cadastro até o fim