Skip to content

Instantly share code, notes, and snippets.

@daviwesley
Last active September 30, 2019 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviwesley/b32473d7c0a3a977cc60ba91a53242f4 to your computer and use it in GitHub Desktop.
Save daviwesley/b32473d7c0a3a977cc60ba91a53242f4 to your computer and use it in GitHub Desktop.
import os
import platform
import time
import csv
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
def check_user(user):
"""
Checa se um usuário existe dentro do site https://www.tibia.com
lendo uma lista de emails contido no arquivo "emails.txt" e grava
os emails válidos em um arquivo "emails_validos.csv"
info:
faça o download do driver nesse link
https://sites.google.com/a/chromium.org/chromedriver/
"""
url = "https://www.tibia.com/account/?subtopic=createaccount"
ok = 'background-image: url("https://static.tibia.com/images/global/general/ok.gif");' # ngm tem esse email
nok = 'background-image: url("https://static.tibia.com/images/global/general/nok.gif");'# alguem ja tem esse email
c = csv.writer(open("emails_validos.csv", "w"))
c.writerow(["E-mail", "Status"])
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=1920x1080")
browser = ""
if platform.system() == "Linux":
browser = "chromedriver"
else:
browser = "chromedriver.exe"
browser = os.path.join(os.getcwd(), browser)
driver = webdriver.Chrome(
chrome_options=chrome_options, executable_path=browser)
driver.get(url)
email = driver.find_element_by_id('email')
status = driver.find_element_by_id("email_indicator")
error = driver.find_element_by_id("email_errormessage")
msg = "This email address is already used. Please enter another email address!"
# realizar checagem
for e_mail in user:
email.clear()
email.send_keys(str(e_mail))
status.click()
time.sleep(0.6)
if status.get_attribute("style") == nok and error.text == msg:
print(f'{e_mail} válido')
c.writerow([str(e_mail), "ok"])
email.clear()
driver.quit()
with open("emails.txt") as fp:
email = []
for line in fp:
email.append(line.strip())
check_user(email)
# check_user(["wesley.sud7@gmail.com", "davi@davi.com.br"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment