Last active
May 15, 2019 19:53
-
-
Save JulianaGuama/2bf92e95b3fd8ef114e38a0a7f997c8b to your computer and use it in GitHub Desktop.
A webScrap com Selenium em Python
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
class wordpress_login: | |
url = r'https://wordpress.com/log-in/pt-br?redirect_to=https%3A%2F%2Fwordpress.com%2F' | |
def __init__(self, user, phantomjs): | |
self.user = user | |
self.phantomjs = phantomjs | |
def login(self): | |
from selenium import webdriver | |
from selenium.common.exceptions import NoSuchElementException | |
driver = webdriver.PhantomJS(self.phantomjs); | |
driver.get(self.url); | |
driver.find_element_by_id("usernameOrEmail").send_keys(self.user); | |
driver.find_element_by_class_name("button form-button is-primary").click(); | |
try: | |
output = 'Error' + driver.find_element_by_id("form-input-validation is-error").text; | |
except NoSuchElementException: | |
output = 'Passou!'; | |
driver.quit(); | |
return (output) | |
#rodando o script | |
user = '[email protected]' | |
phantomjs = r'C:/Users/my_user/my_file_location/phantomjs.exe' | |
scrap = wordpress_login(user, phantomjs) | |
print( scrap.login ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment