1

There's this massively unruly thread that I've got to handle. Each of these emails was just replied to normally, so it didn't matter much that each one had the complete history with it, until it reached a few hundred emails.

So, I opened them all in Thunderbird, and exported them. Now, I've got to find a way to strip each email down to only its own contents. Keep the reply-to bits, but just get rid of the actual contents of those other emails.

I'm using Python at the moment, because I'm familiar with it, and have used it for XML parsing before. I tried BeautifulSoup, which seemed to work great at stripping out the 3D"gmail_quote" div elements, but in doing so, it seems to have tried to make sense of the rest of the .eml file by wrapping various bits in other elements, and ruining the format.

So, I need to find a way to strip, from a file which is not pure XML but contains a lot of valid XML, every instance of a particular div class and its children, without touching the plain text. The section I want to work with is all valid XML (or, close enough for BeautifulSoup with the odd quotes on the attributes).

I know I'll also have to strip out the reply in the body, but that's easy enough.

1 Answer 1

0

Without seeing a sample, I can't say for sure how to accomplish what you need, but the parser from the email module should handle parsing the .eml files.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.