Source code for social.facebook

# -*- coding: utf-8 -*-
"""
=======================================================================================
social.facebook module contains classes and methods specific to Facebook social network
=======================================================================================

   .. warning:: Coding style is CamelCase for classes and lowercase_separated_by_underscores A.K.A snake_case for
      methods and variables.
"""
from time import sleep


[docs]class Facebook: """ **Specificity of Facebook** at the moment, the classes specifies the login and post method Facebook. Contain also constant of the social network. """ name = "Facebook" url = "https://www.facebook.com/" home = "mainContainer"
[docs] @staticmethod def login_submit(driver, login, password): """ Log in Facebook :param driver: Selenium driver of the bot :param login: Login to use for this bot :param password: Password to use for this bot """ email_input = driver.find_element_by_id("email") email_input.send_keys(login) sleep(0.25) password_input = driver.find_element_by_id("pass") password_input.send_keys(password) submit_button = driver.find_element_by_id('loginbutton') submit_button.click()
[docs] @staticmethod def post(driver, message): """ Method that defines the actions to post a message on Facebook :param driver: Selenium driver of the bot :param message: Message to post on Facebook """ post_input = driver.find_element_by_css_selector('div._1mf') post_input.click() post_input = driver.find_element_by_css_selector("div.notranslate._5rpu") sleep(0.25) post_input.send_keys(message) sleep(0.1) submit_button = driver.find_element_by_css_selector('button._1mf7') submit_button.click()