Download Facebook Video Using Python - CodeSpeedy
Maybe your like
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
- 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.
- The code for downloading:import sys import os import requests as r import wget filedir = os.path.join('C:/Users/varsh/Downloads') try: LINK = "https://www.facebook.com/peopleareawesome/videos/637730157348346/" #url of video to be downloaded html = r.get(LINK) except r.ConnectionError as e: print("Error in connecting") except r.Timeout as e: print("Timeout") except r.RequestException as e: print("Invalid URL") except (KeyboardInterrupt, SystemExit): print("System has quit") sys.exit(1) except TypeError: print("Video seems to be private ") else: print("\n") print("Video Quality:Normal " ) print("[+] Starting Download") wget.download(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;
urllib.request.urlretrieve(url, filepath)
Also read, Facebook and YouTube video downloader PHP script
4 responses to “Download Facebook video using Python”
- David Chen says: November 9, 2022 at 10:33 pm
The python code “wget.download(LINK,filedir)” I run has the following message: FileNotFoundError: [Errno 2] No such file or directory: ‘C:/Users/varsh/Downloads0xzdykam.tmp’
How to fix this this problem? Appreciate your help!
Best, David Chen
Reply- Saruque Ahamed Mollick says: November 9, 2022 at 10:59 pm
Kindly put your path instead of C:/Users/varsh/Downloads.
Reply
- Saruque Ahamed Mollick says: November 9, 2022 at 10:59 pm
- Manan Aggarwal says: November 25, 2022 at 11:32 am
wget downloads wget file, not a mp4 file.
Reply - Cebo says: December 10, 2022 at 4:27 am
the downloaded file is a .wget and not a .mp4, plz help on how to fix this ?
Reply
Leave a Reply Cancel reply
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
« How to delete elements smaller than a specific value from a list in PythonCheck if string is number in C++ » Search
Related Posts
Tag » How To Download Facebook Videos With Pageurl Python
-
How To Download Facebook Videos With Pageurl Using Python?
-
How To Download Facebook Videos With Page Url Python
-
How To Download Facebook Videos With Pageurl Python? [Answer]
-
How To Download Facebook Videos With Pageurl Python - Infobizzz
-
How To Download Facebook Videos With Pageurl Using Python
-
How To Download Facebook Video With Python | TesKill - YouTube
-
Top 10 How To Download Facebook Videos With Page Url Python
-
Python Script To Download Facebook Videos | By Ansh Goyal
-
Reverse Engineering Facebook: Public Video Downloader
-
Downloading Facebook Videos From The Blob Infrastructure Via Python
-
Decoding Facebook's Blob Video Url - Stack Overflow
-
OEmbed - Social Plugins - Documentation - Facebook For Developers
-
Python Script To Download Facebook Videos
-
Custom Home Page For Published Apps - Azure Active Directory ...