This Python script uses Selenium and BeautifulSoup to download Facebook albums. The script was originally created to backup the latest 60 albums from the old ICPS Facebook page to the new page.
Note :- I created this script to solve an immediate problem and meet a pressing need. Since I had limited time due to my A/L examination, the code was not optimized or designed with best practices in mind. My primary goal was to get the job done as quickly as possible, and I did not have the luxury of dedicating extra time to make it more elegant or efficient. Therefore, the code might be difficult to read, not scalable, or prone to errors. Despite its limitations, it served its purpose and allowed me to complete the task at hand.
- Python 3.x
- Required libraries:
os
,time
,json
,requests
,bs4
,selenium
,tqdm
- Chrome Browser
chromedriver.exe
(download the driver for your Chrome version from here)
- Clone the repository and navigate to the project directory.
- Install the required libraries:
pip install -r requirements.txt
- Download and install the
chromedriver.exe
and save it in the project directory. - Run the script:
python album_downloader.py
- The script will prompt you to log in to Facebook.
- After login, the script will automatically download all the albums from the Facebook page specified in the
target_url
variable in the script.
The script will prompt you to log in to Facebook. After logging in, it will download the images from the albums on the Facebook page specified in the target_url variable. By default, the first 52 albums found on the page will be downloaded. You can change this by modifying the album_links variable.
The downloaded images will be saved in a directory named albums
in the same directory as the script. The metadata for each album will be saved in a metadata.json
file in the album directory.
Note 1: The script is set up to exclude certain album links (specified in the ``exclude_album_links` variable) to avoid downloading duplicate albums. You can modify this list to exclude additional albums if necessary.
Note 2: The script is set up to wait for 30 seconds after navigating to each album link to allow for the images to load. You can modify this time by changing the time.sleep(30)
line in the script. (I Update this and it's now scrolling automatically. But Sometimes it's may be not working)
Note 3: The script is set up to use the Chrome WebDriver. If you are using a different browser, you will need to modify the script accordingly.
albums/
├── Album 1/
│ ├── photo1.jpg
│ ├── photo2.jpg
│ └── metadata.json
├── Album 2/
│ ├── photo1.jpg
│ ├── photo2.jpg
│ └── metadata.json
|── Album 3/
| ├── photo1.jpg
| ├── photo2.jpg
| └── metadata.json
|
Please respect the privacy and copyright of the owners of the albums you download using this script.
This project is licensed under the MIT License - see the LICENSE file for details.
This script was created by MrBhanuka.
Note: Please make sure to replace folder_path in the README.md file with the actual path to your music folder.