Tech Updates

How to Download Facebook Videos with Pageurl Using Python

Here is how to download Facebook Videos with Pageurl Using Python, With time, social media has emerged as an eminent medium for social interaction, sharing of content and news. One of these social media applications is Facebook, which has made it easier to keep in touch with friends and share content.

Often, you may have even felt compelled to download some videos for later use. On Facebook, there are many fun and informative videos. As a Python enthusiast, you must be excited to know that you can also download Facebook videos using Python.

In this tutorial, we will learn how to do that.

Download Facebook Videos with Pageurl Using Python

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.

Here is the code to download facebook videos using python

import sys
import os
import requests as r
import wget
filedir = os.path.join('C:/Users/varsh/Downloads')
LINK = "" #url of video to be downloaded
html = r.get(LINK)
except r.ConnectionError as e:
print("Error in connecting")
except r.Timeout as e:
except r.RequestException as e:
print("Invalid URL")
except (KeyboardInterrupt, SystemExit):
print("System has quit")
except TypeError:
print("Video seems to be private ")
print("Video Quality:Normal " )
print("[+] Starting Download"),filedir)
print("Video downloaded")
Video Quality:Normal 
[+] Starting Download
-1 / unknown

Video downloaded
Therefore, the code above will download the Facebook video whose URL is specified while defining the link.
You can also specify the location where you want to store it as a parameter in the download() method.
Alternatively, you can find the downloaded file in the current directory.
You can also perform the downloading urllib library instead of wget.
The syntax for the same;
urllib.request.urlretrieve(url, filepath)

Sponsored Links
Back to top button