How to automating Facebook posts using python script.

learn How to automating Facebook posts using python script?
How to automating Facebook posts

Welcome everyone to another my interesting python post article, Do you want to learn How to automating Facebook posts using python script? but you Don’t know how to do it? then please follow the below methods and instruction. so let’s start: 

we know that Facebook is the world most popular social media platform so many of them people definitely share your content on it.

Also see : python security update 3.7.9

The below script helps you to login you to Facebook and post on your news feed.

Step 1 : You need to first download Python selenium package , this package help to automate this task.

 so if some cases you don’t installed python selenium in your system set-up , then use the below command to install it.

pip install selenium

Step 2 : Below entire script help you to automating Facebook post using python script.

# How to automating Facebook post using python script.

from selenium import webdriver

import time

email = '' //Your Email Here

pwd = '**********' //Your Password Here


msg = 'Learn How to automating Facebook post using python script with pythonslearning.' //Your Post or Message Here


driver = webdriver.Chrome('chromedriver.exe')




user =  driver.find_element_by_id('email')

password = driver.find_element_by_id('pass')


button = driver.find_element_by_id('u_0_b')



body =  driver.find_element_by_xpath('/html/body/div[1]/div/div/div[1]/div[3]/div/div/div[1]/div/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[1]')


message = driver.find_element_by_xpath('/html/body/div[1]/div/div/div[1]/div[4]/div/div/div[1]/div/div[2]/div/div/div/form/div/div[1]/div/div[2]/div[2]/div[1]/div[1]/div[1]/div/div/div/div/div[2]/div/div/div/div')



post = driver.find_element_by_xpath('/html/body/div[1]/div/div/div[1]/div[4]/div/div/div[1]/div/div[2]/div/div/div/form/div/div[1]/div/div[2]/div[3]/div[2]/div')


By using this code script we automating Facebook post and news feed.

Some point must be remember :

 You need to give your password, email and message on require fields. 

Also see : python method vs function vs class

Some FAQ about automating Facebook posts using python script.

How do I post to Facebook using Python?

In this article we see in detailed How to post to Facebook using Python. 
second way is :
we need access_token for it. graph = facebook. GraphAPI(access_token=”##XXXXXXXX##”) print graph #to post to your news feed.

How do I find my Facebook access token?

Follow the below step in sequence :
#1 Press button Add New App>
#2 Press button Create App ID and enter the capture into the capture field.
#3 Press button Get Token and select Get User Access Token.
#4 and finally Check the required options on the popup window and choose the permissions needed for your app.

Summary :

In this article we saw the How to automating Facebook post using python script. so friends any problem about this section then please comment me.


I am the founder of Pythonslearning, a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

Leave a Comment