Last active
July 1, 2020 15:36
-
-
Save checchia/b18a6845534f67241768938d040b99bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.common.keys import Keys | |
from selenium.webdriver.support.ui import Select | |
from selenium.common.exceptions import NoSuchElementException | |
from sty import fg, bg, ef, rs | |
def valida_inpi(nome_marca): | |
print(" ") | |
asc_text = fg.green + ef.bold + nome_marca + rs.bold_dim + fg.rs | |
print("validando {} no INPI".format(asc_text)) | |
url = 'https://gru.inpi.gov.br/pePI/servlet/LoginController?action=login' | |
option = webdriver.ChromeOptions() | |
option.add_argument('--ignore-certificate-errors') | |
option.headless = True | |
driver = webdriver.Chrome('/usr/local/bin/chromedriver', options=option) | |
driver.maximize_window() | |
driver.get(url) | |
time.sleep(2) | |
driver.get('https://gru.inpi.gov.br/pePI/jsp/marcas/Pesquisa_num_processo.jsp') | |
time.sleep(2) | |
driver.get('https://gru.inpi.gov.br/pePI/jsp/marcas/Pesquisa_classe_basica.jsp') | |
time.sleep(2) | |
driver.find_element_by_name('marca').send_keys(nome_marca) | |
driver.find_element_by_name('botao').click() | |
result = driver.page_source | |
time.sleep(5) | |
if "Foram encontrados" in result: | |
return {"msg": "Marca já registrada"} | |
elif "Nenhum resultado foi encontrado para a sua pesquisa" in result: | |
return {"msg": "Marca Disponível"} | |
else: | |
return {"msg": "Erro inesperado :-)"} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment