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 = 'pythonslearning@gmail.com' //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')

 

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

 

user =  driver.find_element_by_id('email')

user.send_keys(email)
password = driver.find_element_by_id('pass')

password.send_keys(pwd)

button = driver.find_element_by_id('u_0_b')

button.submit()

time.sleep(10)

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]')

body.click()

time.sleep(5)

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')

message.send_keys(msg)

time.sleep(10)

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')

post.click()

#driver.close()

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.

BEST OF LUCK !!!

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