Here's How You Can Build A Python Bot Which Automatically Logs In To Facebook For You!!

Line By Line Explanation Of The CodeπŸ‘‡πŸ§΅

#100DaysOfCode #CodeNewbie #DEVCommunity
#coder #Python #Automation #Facebook
Before I Start The Explanation, This Is A Recording Of What The Code Does.

πŸ‘‡
In The 1st Line, We Are Importing Selenium.

@SeleniumHQ Is A Tool Which Helps Us Automate Tasks In Web Browsers. We Can Automatically Click Buttons, Fill Text Fields, Get The Data From Web Page And Many Other Things, All By Code.

πŸ‘‡
In The 2nd Line We Are Giving The Path To Our Webdriver, In This Case The Chrome Webdriver (We Can Use Other Browsers Too).

You Can Download The Chrome Webdriver Here :

chromedriver.chromium.org/downloads

πŸ‘‡
In The 3rd Line, We Are Just Telling The Browser To Open A Website, Which In This Case Is facebook.com

In The 4th And 5th Line, We Are Just Saving Our Username And Password In Variables, These Values Would Be Put On The Text Fields On The Facebook Login Page

πŸ‘‡
After The FB Login Page Is Opened

In The 6th And 7th Lines, We Are Finding The Text Fields On The Page With The 'id' Their HTML Tags Are Given

Now How Did I Get Those?

Just Right Click On The Text Field And Click On Inspect, A Window With A Lot Of HTML Code Will Open Up

πŸ‘‡
There Will Be Some Highlighted Code, In This Case It Will Be An Input Tag Which Several Attributes, The Attribute We Are Interested In Is 'id'.

So Go Ahead And Copy The Value Of The 'id' Onto Your Code.

The ID Helps Selenium Recognize Which Text Field We Are Looking For

πŸ‘‡
Now After We Have Found Our Text Fields, We Want To Fill In Our Details There.

In The 8th And 9th Lines, Tell Selenium To Fill In Our Email And Password In Our Text field.

πŸ‘‡
In The 10th Line, We Our Finding Our Login Button On The Page In The Same Way We Did For Our Text Fields.

And All The 11th Line Does Is To Tell Selenium To Click On That Login Button.

And There You Go, Your Logged In Account Will Open Up In Your Browser

πŸ‘‡
THATS IT!!

JUST 11 LINES OF CODE!

And You Build A Python Bot Which Automatically Logs In To Facebook For You!

This Is How Easy It Is

πŸ‘‡
If You Learnt Something New Today And Liked It,

Then Please Like And RT This Thread So More People See It!!

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Krish Nerkar

Krish Nerkar Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @nerkar_krish

22 Nov
One Of The Most Common Misconceptions People Starting Out With Machine Learning Have Is,

You Need An Expensive Laptop With A Good GPU To Train Machine Learning Models.

Lets Break Down This Misconception And Why It Is FalseπŸ‘‡πŸ§΅

#100DaysOfMLCode #MachineLearning #CodeNewbie #AI
Introducing Google Colab.

Now What Is @GoogleColab?

This Is What Their Documentation Says :

"Colab allows anybody to write and execute arbitrary python code through the browser, and is especially well suited to machine learning, data analysis and education."

πŸ‘‡
In Simple Words,

Google Colab Let's You Write Python Code In the Browser And Executes It On Their Cloud CPU, GPU or TPU.

How Does This Help Us In Any Way?

πŸ‘‡
Read 6 tweets
21 Nov
What Is Asynchronous Code?

Explained With An Analogy And Code Examples In Python And JavaScriptπŸ‘‡πŸ§΅

#100DaysOfCode #CodeNewbie #DEVCommunity #programming #Python #javascript
Asynchronous Code Is The Code Which Runs Asynchronously In The Background While The Further Code Executes.

Now What Do I Mean By That?

πŸ‘‡
Lets Understand This With A Simple Analogy:

Consider You Are A Cashier At KFC.

Someone Comes And Gives You An Order For 3 Burgers And 2 Large French Fries.

The Burgers Are Not Ready Yet So You Tell The Person To Wait For 5-10 Minutes For His Order To Get Completed

πŸ‘‡
Read 9 tweets
20 Nov
Ever Wondered Where To Host Your Next Project Or Website For No Cost At All.

Here Is A List Of Sites Which Offer Free Hosting πŸ‘‡:

#100DaysOfCode #DEVCommunity #webdev
1. GitHub Pages

Its One Of The Most Popular Places To Host Your Static Website. All You Need Is A @github Account. Check Out Their Guide On How To Host Here -

pages.github.com
2. Heroku

If You Want To Host Your Bot Or Your Dynamic Website Or Any Program, @heroku Is One Of The Best Places To Start, Go Ahead Create An Account And Upload Your Project And Get It Up And Running In Less Than 10 mins. Check Them Out Here -

heroku.com
Read 6 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!