fbot.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:fbot 作者: eracle 项目源码 文件源码
def login(email, password):
    """
    Performs a Login to the Facebook platform.
    :param email: The used email account.
    :param password: Its password
    :return: Returns the logged Selenium web driver and the user name string.
    """
    logger.info('Init Firefox Browser')
    profile = webdriver.FirefoxProfile()
    profile.set_preference('dom.disable_beforeunload', True)
    driver = webdriver.Firefox(profile)

    driver.get('https://www.facebook.com')

    logger.info('Log in - Searching for the email input')
    get_by_xpath(driver, '//input[@id="email"]').send_keys(email)

    logger.info('Log in - Searching for the password input')
    get_by_xpath(driver, '//input[@id="pass"]').send_keys(password)

    logger.info('Log in - Searching for the submit button')
    get_by_xpath(driver, '//input[@type="submit"]').click()

    logger.info('Log in - get the user name')
    user_name = get_by_xpath(driver, '//a[@class="fbxWelcomeBoxName"]').text

    logger.info('Log in - Saving the username, which is: %s' % user_name)
    return driver, user_name
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号