Я пытаюсь извлечь количество таблиц, количество изображений из MSG-файлов в Python.
Ранее я использовал пакет win32com, и он выдавал ожидаемый результат. Я пытаюсь повторить то же самое в Mac, но не могу найти соответствующие пакеты, чтобы получить требуемый вывод
Рабочий код в Windows:
import win32com.client
from bs4 import BeautifulSoup
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem(r"C:\\Users\\sowmiyan\\Sample.msg")
html = msg.HTMLBody
soup = BeautifulSoup(html )
tables = soup.findAll("table")
count_tables=len(tables)
count_attachments = msg.Attachments.Count
image_format_list=['png','jpg','tif','gif']
count_images = 0
if count_attachments > 0:
for item in range(count_attachments):
if msg.Attachments.Item(item + 1).Filename.split(".")[-1] in image_format_list:
count_images+=1
print(count_tables)
print(count_images)
Может кто-нибудь предоставитьнекоторые указатели, чтобы он работал в MAC