0% found this document useful (0 votes)
34 views3 pages

Download Facebook Videos with Python

This document provides a tutorial on how to download Facebook videos using Python. It outlines the necessary modules to import, including sys, os, requests, and wget, and provides sample code to execute the download. Additionally, it mentions an alternative method using the urllib library for downloading videos.

Uploaded by

Menberu Munye
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views3 pages

Download Facebook Videos with Python

This document provides a tutorial on how to download Facebook videos using Python. It outlines the necessary modules to import, including sys, os, requests, and wget, and provides sample code to execute the download. Additionally, it mentions an alternative method using the urllib library for downloading videos.

Uploaded by

Menberu Munye
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Download Facebook video using Python

With time, social media has emerged to be an eminent medium for social
interaction, sharing of content, news etc. Facebook is one such social media
application that made keeping up with friends and viewing/sharing content
easier than ever. You must have come across many fun as well as informative
videos on Facebook. In certain instances, you may have even felt like
downloading certain videos for later access. Well, as a Python enthusiast you
must be excited to know that you can download any Facebook video using
Python too.

Let us now learn the same through this tutorial.

Steps to download Facebook videos using Python


1. Import necessary modules:
sys– This module is used for manipulating the Python run-time
environment. This helps access interpreter functions and variables.
os– It provides methods for interacting with the operating system.
(accessing different paths etc.).
requests- It is a Python module for sending HTTP requests.
wget- It is a Python download utility module for downloading files from
the internet server.
2. The code for downloading:

import sys

import os

import requests as r

import wget
filedir = [Link]('C:/Users/varsh/Downloads')

try:

LINK =
"[Link]
48346/" #url of video to be downloaded

html = [Link](LINK)

except [Link] as e:

print("Error in connecting")

except [Link] as e:

print("Timeout")

except [Link] as e:

print("Invalid URL")

except (KeyboardInterrupt, SystemExit):

print("System has quit")

[Link](1)

except TypeError:

print("Video seems to be private ")

else:

print("\n")

print("Video Quality:Normal " )


print("[+] Starting Download")

[Link](LINK,filedir)

print("\n")

print("Video downloaded")

Video Quality:Normal
[+] Starting Download
-1 / unknown

Video downloaded

Thus, the above code will download the Facebook video whose URL is
specified while defining the link.
Also, you can specify the path where you want to store it as a parameter
in the download() method.
Otherwise, you can find the downloaded file in the current directory.

Note:
You can also perform the downloading urllib library instead of wget.
The syntax for the same;

[Link](url, filepath)

You might also like