Use Selenium WebDriver and Python to download all images from a Messenger Chat Group.
To download images from a Messenger chat group, you can create an app and use the Messenger API.
This Python snippet is trying to do the same thing, but avoids using the Messanger API as new requirements continuously makes it harder to use the tools from Meta.
Inspired by leoguillaume/fbm-image-scraper.
- Python 3.
- Selenium WebDriver 4 for Python.
- Microsoft Edge WebDriver 114.
- Membership of a Messenger Group Chat.
- Clone the Git repository messenger-chat-images.
- Add the necessary Python package requirements as stated in
requirements.txt
to your virtual environment. - Download the Microsoft Edge WebDriver msedgedriver.exe and add its location to your path.
- Use the file
config-template.ini
as a template for creating a fileconfig.ini
.
The configuration file nees to two entries:
- The username (email address) of the Facebook account.
- The URL of your Group Chat Media.
- The location of your Microsoft Edge default download directory.
Please note: The configuration parser does not accept percent-signs '%'. Prepend any %-signs in the URL's with yet another %-sign: '%%' instead of just '%'.
When the program runs, you will have 1 minute to enter password and login to your facebook account.
- Browse to Messenger.
- Choose the Chat.
- Choose Media and Files.
- Choose Media.
- Choose the latest image.
- Copy the URL.
The URL is of the form:
https://www.messenger.com/messenger_media?attachment_id=999999999999999999&message_id=mid.AAAAAAAAAAAAAAAAAAA&thread_id=9999999999999
Add the URL from above as the media_path
in your config.ini
file.
$ python3 download_images
- The program uses Selenium WebDriver to start Edge.
- You will need to enter your Facebook account password and press the submit button.
- After a minute, the program starts downloading the current image.
- The program continues to second last image.
- The images is downloaded.
- And so the program continues until last image.
The downloaded images are downloaded to the default Downloads directory of Microsoft Edge.