Trích xuất dữ liệu từ email triển vọng python

0. 29. * là nhánh hỗ trợ cả Python 2 và Python 3. Nó hiện chỉ nhận được các bản sửa lỗi và sẽ không nhận được các bản cập nhật tính năng

Cách sử dụng

Để sử dụng nó như một tập lệnh dòng lệnh

python -m extract_msg example.msg

Thao tác này sẽ tạo ra một thư mục mới có tên theo ngày, giờ và chủ đề của thư [ví dụ: “2013-07-24_0915 Example”]. Bản thân email có thể được tìm thấy bên trong thư mục mới cùng với các tệp đính kèm

Tập lệnh sử dụng mô-đun Python của Philippe Lagadec để đọc các tệp Microsoft OLE2 [còn được gọi là Lưu trữ có cấu trúc, Định dạng nhị phân tệp hợp chất hoặc Định dạng tệp tài liệu hợp chất]. Đây là định dạng cơ bản của Outlook. tập tin msg. Thư viện này hiện hỗ trợ Python 3. 6 trở lên

Kịch bản ban đầu được xây dựng bằng cách sử dụng tài liệu của Peter Fiskerstrand về. định dạng tin nhắn. Cuộc thảo luận của Redemption về các loại thuộc tính khác nhau được sử dụng trong MAPI mở rộng cũng rất hữu ích. Để tham khảo trong tương lai, lưu ý rằng Microsoft đã mở tài liệu của họ về định dạng tệp, đây là những gì hiện đang được sử dụng để phát triển

######### GHI LẠI CÁCH SỬ DỤNG DÒNG LỆNH############# Hiện tại, README đang trong quá trình làm lại. Hiện tại, vui lòng tham khảo thông tin sử dụng được cung cấp từ hộp thoại trợ giúp của chương trình

usage: extract_msg [-h] [--use-content-id] [--dev] [--validate] [--json] [--file-logging] [--verbose] [--log LOG] [--config CONFIGPATH] [--out OUTPATH] [--use-filename]
               [--dump-stdout] [--html] [--pdf] [--wk-path WKPATH] [--wk-options [WKOPTIONS ...]] [--prepared-html] [--charset CHARSET] [--raw] [--rtf]
               [--allow-fallback] [--zip ZIP] [--attachments-only] [--no-folders] [--skip-embedded] [--out-name OUTNAME | --glob] [--ignore-rtfde] [--progress]
               msg [msg ...]

extract_msg: Extracts emails and attachments saved in Microsoft Outlook's .msg files. //github.com/TeamMsgExtractor/msg-extractor

positional arguments:
  msg                   An MSG file to be parsed.

optional arguments:
  -h, --help            show this help message and exit
  --use-content-id, --cid
                        Save attachments by their Content ID, if they have one. Useful when working with the HTML body.
  --dev                 Changes to use developer mode. Automatically enables the --verbose flag. Takes precedence over the --validate flag.
  --validate            Turns on file validation mode. Turns off regular file output.
  --json                Changes to write output files as json.
  --file-logging        Enables file logging. Implies --verbose level 1.
  -v, --verbose         Turns on console logging. Specify more than once for higher verbosity.
  --log LOG             Set the path to write the file log to.
  --config CONFIGPATH   Set the path to load the logging config from.
  --out OUTPATH         Set the folder to use for the program output. [Default: Current directory]
  --use-filename        Sets whether the name of each output is based on the msg filename.
  --dump-stdout         Tells the program to dump the message body [plain text] to stdout. Overrides saving arguments.
  --html                Sets whether the output should be HTML. If this is not possible, will error.
  --pdf                 Saves the body as a PDF. If this is not possible, will error.
  --wk-path WKPATH      Overrides the path for finding wkhtmltopdf.
  --wk-options [WKOPTIONS ...]
                        Sets additional options to be used in wkhtmltopdf. Should be a series of options and values, replacing the - or -- in the beginning with + or ++,
                        respectively. For example: --wk-options "+O Landscape"
  --prepared-html       When used in conjunction with --html, sets whether the HTML output should be prepared for embedded attachments.
  --charset CHARSET     Character set to use for the prepared HTML in the added tag. [Default: utf-8]
  --raw                 Sets whether the output should be raw. If this is not possible, will error.
  --rtf                 Sets whether the output should be RTF. If this is not possible, will error.
  --allow-fallback      Tells the program to fallback to a different save type if the selected one is not possible.
  --skip-body-not-found Skips saving the body if the body cannot be found, rather than throwing an error.
  --zip ZIP             Path to use for saving to a zip file.
  --save-header         Store the header in a separate file.
  --attachments-only    Specify to only save attachments from an msg file.
  --skip-hidden         Skips any attachment marked as hidden [usually ones embedded in the body].
  --no-folders          When used with --attachments-only, stores everything in the location specified by --out. Incompatible with --out-name.
  --skip-embedded       Skips all embedded MSG files when saving attachments.
  --extract-embedded    Extracts the embedded MSG files as MSG files instead of running their save functions.
  --out-name OUTNAME    Name to be used with saving the file output. Cannot be used if you are saving more than one file.
  --glob, --wildcard    Interpret all paths as having wildcards. Incompatible with --out-name.
  --ignore-rtfde        Ignores all errors thrown from RTFDE when trying to save. Useful for allowing fallback to continue when an exception happens.
  --progress            Shows what file the program is currently working on during it's progress.

Để sử dụng điều này trong tập lệnh của riêng bạn, hãy bắt đầu bằng cách sử dụng

import extract_msg

Từ đó, mở tệp MSG

msg = extract_msg.openMsg["path/to/msg/file.msg"]

Ngoài ra, nếu bạn muốn gửi một chuỗi nhị phân msg thay vì một tệp tới extract_msg. phương pháp openMsg

msg_raw = b'\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1\x00 .. \x00\x00\x00'
msg = extract_msg.openMsg[msg_raw]

Nếu bạn muốn ghi đè lớp đính kèm mặc định và sử dụng lớp của riêng mình, chỉ cần thay đổi mã thành

msg = extract_msg.openMsg["path/to/msg/file.msg", attachmentClass = CustomAttachmentClass]

trong đó CustomAttachmentClass là lớp tùy chỉnh của bạn

#LÀM. Kết thúc phần này

Nếu bạn có bất kỳ câu hỏi nào, vui lòng liên hệ với Destiny tại arceusthe [at] gmail [dot] com. Cô là đồng sở hữu và nhà phát triển chính của dự án

Chủ Đề