How to scrape iMessages in Python?

597 Views Asked by At

Recently, I've tried completing a project that involves sending a message from my iPhone to my Macbook. This by taking usage of the new shortuts feature on iPhone. (Note that my MacBook has to be able to pick up the message with Python and automatically. Otherwise, this will not work since the project involves a remote controlling of my Computer.)

When writing the message through shortcuts, I'd like to take use of the ask for Input action to make the shortcuts look as clean as possible. To try and accomplish this using python/shortcuts scripts (one for the sender and one for the listener) requires that I take usage of iMessages or Icloud Email. Otherwise I'll be having to write the actuall message within another App or similar. For instance the Send Message via Discord action works by having you manually writing the message within the Discord App, which worsens the experience.

Hence I've looked for solutions, python scripts that can scrape my last Email or iMessage.

The most promising solution that I've come across involves the python package "iMessage_reader", link. -->

from imessage_reader import fetch_data

DB_PATH = '/Users/marcojohanssontornblom/Desktop/Messages/chatRenderMetaData.db'

# Create a FetchData instance
fd = fetch_data.FetchData(DB_PATH)

# Store messages in my_data
# This is a list of tuples containing user id, message and service (iMessage or SMS).
my_data = fd.get_messages()
print(my_data)

But this script returns this output: `Error reading the database: no such table: message Did you specify the correct path?

Process finished with exit code 1`

And there is seemingly no document called "chat.db", most similar being "chatRenderMetaData.db". But using that document obviosuly didn't work.

And to try scraping the Email is even worse of an option. Sure, there are tips on how to extract email manually, same goes for SMS conversations. But any scraping script doesn't seem to exist.

Any thoughts?

0

There are 0 best solutions below