Code Monkey home page Code Monkey logo

fb-message-parser's Introduction

Facebook Message Export Parser

Facebook has a feature that allows users to download a copy of their data as a zip archive containing htm files with their data. The aim of this parser is to take this archive and to extract a user's Facebook Messages from it; to transfer them into a more useful format, as well as performing some analysis to produce interesting data.

Running the Code

The Facebook Export can be downloaded from the Facebook Settings menu.

Run "python fb_parser.py" with the 'messages.htm' file in the same directory to export to JSON as proof of concept.

Dependencies

The code is written in Python 3+. The parser uses BeautifulSoup to do the bulk of the capture from the htm file.

Anaconda Python for scientific computing is a simple and easy way to install all the dependencies for the code, alongside many other useful libraries. It can be downloaded here.

fb-message-parser's People

Contributors

copontherun avatar jsharkey13 avatar sinwoobang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fb-message-parser's Issues

ValueError: unconverted data remains: +08

Hi, I trying your project, still fresh in python, but I do install Anaconda and put messenger.htm as same directory, below is the output I get, any idea?

Macbooks-MBP:FB-Message-Parser-master Kira$ python fb_parser.py 
/Users/macbook/anaconda/lib/python3.6/site-packages/bs4/__init__.py:181: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.

The code that caused this warning is on line 76 of the file fb_parser.py. To get rid of this warning, change code that looks like this:

 BeautifulSoup(YOUR_MARKUP})

to this:

 BeautifulSoup(YOUR_MARKUP, "lxml")

  markup_type=markup_type))
Traceback (most recent call last):
  File "fb_parser.py", line 76, in <module>
    chat = html_to_py(f)
  File "fb_parser.py", line 25, in html_to_py
    dt.strptime(y.find(class_='meta').string.replace("+01", ""), dtFormat),
  File "/Users/macbook/anaconda/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/Users/macbook/anaconda/lib/python3.6/_strptime.py", line 365, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: +08

The __lt__, __gt__, and __eq__ operators implement incorrect comparisons.

In the fb_chat file in the Message class, the Python comparison operators compare the wrong thing:
They currently use the sent_before() function, which takes a date as an argument. However, the lt operator receives a Message object as an argument.

    def __lt__(self, date):
        return self.sent_before(date)

    def sent_before(self,date):
        return self.date_time < date

To perform the correct comparison, the Message.date_time should be passed to sent_before()

def __lt__(self, message):
        return self.sent_before(message.date_time)

and similarly for the gt method.

Message Viewer

Great project!

A side tool could be a conversation viewer, reading the JSON. Opened in a browser, the messages would be browsable, separated by conversations/persons, searchable, etc. All the things the local archive messages html file doesn’t do but the online original message feature does.

Time format not matching

Hi, thanks for making this!

I get this error when parsing my archive:

ValueError: time data 'Friday, 19 June 2015 at 19:17 UTC+02' does not match format '%A, %B %d, %Y at %I:%M%p %Z'

I guess there can be format inconsistencies in an archive, and the tool doesn’t expect that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.