As we are aware that there are multiple tasks in the marketing agencies which are happening manually, and one of those tasks is bulk posting on several Facebook pages, which is very time-consuming and sometimes very tedious to do.
In this project-based article, we are going to explore a solution that is on the python selenium library and see how we can use it & implement this to use it in our daily life.
- Python selenium library (This library is like API to access the selenium web driver to control Chrome, Firefox, etc.
- Chromium Web drivers (To use & Control Chrome browser, this driver requires to present in your system)
- To install selenium.
pip install selenium
- For web driver, you need to download the chromedriver.exe file and need to put it in the same folder where you have extracted this project.
Note: Also provided the chromedriver.exe with the project. But it is better to download the latest driver from the official website to avoid the version issues.
Let’s explore the project files:
- PostingContents.txt: In this file, We need to give content which we want to publish on Facebook Pages.
- credentials_load.json: In this JSON file, we need to give these details:
- In the “Page Names” field, you need to give your Facebook Page names where we want to publish the content. Page names should come between double string quotes. For example, I have added some of my Facebook page names, replace them with your pages.
- In the “Email Address” field, you need to give your Facebook login email address, and this information is only to log in to Facebook.
- In the “Password” field, you need to give your Facebook password to log in. This information is only to log in to Facebook.
How does it work?
For bulk posting, the script does a couple of things:
- Loads credentials_loads.json and posting content file to use it for login and posting purpose
- Open the Chrome browser and loads the Facebook login Page.
- Once the Login page is loaded, it automatically fills the login email address and password (will take from credentials_loads.json file).
- After that script pauses and tells the user to perform actions like Permit the login if 2FA enable after that, show notification box appears (click on the block option)
- After completing those tasks, type “y” in the cmd (where the script is running) and click ENTER so that script can start running.
- Now, the script loads the Facebook pages list and open the given page (mentioned pages in the credentials_loads.json file) one by one and post the content. In each posting, the script pauses for some seconds so that elements can load completely. Otherwise, it will raise some errors.
- After completing posting works, the script will automatically log out and close the chrome.
Below is the implementation:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.