我每天都会收到一封包含数据Feed的电子邮件。电子邮件包含一个zip文件,其中包含一个包含xml数据的txt文件。如何使用python自动提取此数据?当前,我已经创建了一个自定义程序,该程序从xml格式中提取数据,但是我需要手动将文本文件另存为xml文件,然后运行该模块。有没有办法自动执行此过程?
包含xml数据的txt文件示例
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:c="http://base.google.com/cns/1.0" xmlns:g="http://base.google.com/ns/1.0">
<title>Recipes</title>
<link type="text/html" rel="alternate" href="https://www.recipes.com/recipe"/>
<updated>2019-02-05T11:30:51Z</updated>
<author>
<name>Recipes</name>
</author>
<id>https://www.recipes.com/recipe</id>
<entry>
<title>Salt & Vinegar French Fries</title>
<summary>These crispy fries derive their bright, lively flavor from a sprinkling of malt vinegar sea salt, a British-inspired blend of tangy malt vinegar powder and sea salt.</summary>
<id>salt-vinegar-fries</id>
<g:image_link>https://www.recipes.com/wsimgs/ab/images/dp/recipe/201851/0009/img88t.jpg</g:image_link>
<link href="https://www.recipes.com/recipe/salt-vinegar-fries.html"/>
<g:main_ingredient>Vinegar, Potato</g:main_ingredient>
<g:meal_type>Side Dish</g:meal_type>
<g:preparation_time>20</g:preparation_time>
<g:servings>8</g:servings>
<g:cooking_time>10</g:cooking_time>
<g:course>Side Dishes</g:course>
<g:cuisine>American</g:cuisine>
</entry>
<entry>
<title>Spice-Roasted Salmon with Cucumber Salad (Tandoori Spice)</title>
<summary>Combining a dozen seasonings, including chili, paprika, cumin and fragrant menthi leaves, our Indian-inspired tandoori spice lends complex flavor to broiled salmon fillets. A cucumber salad provides a refreshing contrast.</summary>
<id>spice-salmon-cucumber-salad</id>
<g:image_link>https://www.recipes.com/wsimgs/ab/images/dp/recipe/201851/0009/img91t.jpg</g:image_link>
<link href="https://www.recipes.com/recipe/spice-salmon-cucumber-salad.html"/>
<g:main_ingredient>Meal Type, Salmon, Cucumber</g:main_ingredient>
<g:preparation_time>15</g:preparation_time>
<g:servings>4</g:servings>
<g:cooking_time>10</g:cooking_time>
<g:course>Side Dishes</g:course>
<g:cuisine>Indian</g:cuisine>
</entry>
<entry>
<title>Cranberry-Pear Chutney</title>
<summary>Aromatic blue-black juniper berries, which come from a tree in the cypress family, impart a spicy evergreen flavor to this chutney, balanced by floral and woodsy notes. The chutney pairs well with most types of cheese, young or aged. Cow's milk and aged sheep's milk cheeses are good choices, but this tangy chutney is also superb served atop fresh ricotta or soft goat cheese.</summary>
<id>cranberry-pear-chutney</id>
<g:image_link>https://www.recipes.com/wsimgs/ab/images/dp/recipe/201851/0010/img1t.jpg</g:image_link>
<link href="https://www.recipes.com/recipe/cranberry-pear-chutney.html"/>
<g:main_ingredient>Pear, Juniper Berry, Cranberry, Meal Type</g:main_ingredient>
<g:preparation_time>15</g:preparation_time>
<g:servings>9</g:servings>
<g:cooking_time>30</g:cooking_time>
<g:course>Side Dishes</g:course>
<g:cuisine>American-New England</g:cuisine>
</entry>
<entry>