Skip to content

Scrapes Facebook profile pages using a normal login (without an API key)

License

Notifications You must be signed in to change notification settings

gsscoder/facebook-snooper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fb-snooper logo

Facebook Snooper

Scrapes Facebook profile pages and searches profiles using a normal log in (without an API key). Inspired by facebook-scraper. Built with MechanicalSoup.

Install

NOTE: Python 3.7 or higher is required.

To install facebook_snooper from source, follow these steps:

# clone the repository
$ git clone https://github.com/gsscoder/facebook-snooper.git

# change the working directory
$ cd facebook-snooper

# install the package
$ pip install .

You can also install with PyPI:

$ pip install facebook_snooper

Usage

>>> import facebook_snooper
>>> from facebook_snooper.dump import dump_search, dump_info
>>> fb = facebook_snooper.init_session()
>>> fb.log_in('user@account.com', 'user_password')
<facebook_snooper.core.session.Session object at 0x10ffc58d0>
>>> results = fb.search('frank new york')
>>> dump_search(results, pretty=True)
profile frankdecaro https://m.facebook.com/frankdecaro?refid=46
  Frank DeCaro
  Author at Rizzoli New York
  Freelance Writer at The New York Times
profile frankbruninyt https://m.facebook.com/frankbruninyt?refid=46
  Frank Bruni
  The New York Times
  New York, New York
>>> info = fb.profile_info('frankbruninyt')
>>> dump_info(info, pretty=True)
Frank Bruni
Image: https://scontent-fco1-1.xx.fbcdn.net/v/t1.0-1/cp0/e15/q65/p120x120/49...
  work The New York Times
  education Columbia University,
  education UNC Chapel Hill
  education Loomis Chaffee
  education Loomis Chaffee, Windsor, Conn.
  living New York
  living White Plains

Test

Create test directory and data:

$ cd facebook-snooper
$ mkdir tests/pages
>>> import facebook_snooper 
>>> from tests.persistence import save_login, save_current_page
>>> fb = facebook_snooper.init_session()
>>> save_login(fb)
>>> fb.log_in('user@email.com', 'user_password')
...
>>> save_current_page(fb, 'logged')
>>> fb.search('frank new york')
...
>>> save_current_page(fb, 'search')
>>> fb.profile_info('frankbruninyt')
...
>>> save_current_page(fb, 'profile')

Execute tests:

$ python tests/session.py

Disclaimer

  • This package cannot gather nothing more that is publicly visible.
  • Please respect people's privacy and use it ethically.

Notes

  • There is no guarantee that will work if scraped pages change too much.

Contributors