A python scraper using selenium to extract Facebook post data including
- Post ID
- Post Time
- Post Text
- Number of comments, Shares, Emojis (Love, Thankful, Wow, Like, etc)
- Post Link
-
Install Python https://www.python.org/downloads/release/python-371/
-
Install a Python IDE (for example: visual studio code) https://code.visualstudio.com/
-
Download Firefox browser (the program requires Firefox)
-
Install Package Selenium (https://selenium-python.readthedocs.io/installation.html). Using pip, you can install selenium like this:
pip install selenium -
Download the Firefox driver according to your system
-
Unzip the file and move it to C:\Windows\System32
-
Use your IDE to edit the file scraper.py You need to fill in base_url, account, password. (Only if you log in, you can have full access to someone’s home page.)
-
Run this Python file. It would launch a Firefox brower, log in FaceBook for you and go to the base_url you filled in the previous step.
When the program runs, it would look like this
-
When the program finishes, check the csv file in your current folder.
The output file is csv, stored in the same folder as this script.
This scraper is only for educational purpose.
Sometimes, you may need to change the xpath when you get no posts. Move your cursor to one post. Right click. Inspect Element.

