Python美化组HTML解析

Python美化组HTML解析,python,html,parsing,beautifulsoup,Python,Html,Parsing,Beautifulsoup,嗨,伙计们,我对用BeautifulSoup解析HTML有疑问 我的问题是如何解析此html: <div class="time_table show_today" id="monday_schedule"> <h3>January 20, 2014</h3> <table> <tbody> <tr&

嗨,伙计们,我对用BeautifulSoup解析HTML有疑问 我的问题是如何解析此html:

<div class="time_table show_today" id="monday_schedule">
          <h3>January 20, 2014</h3>
                        <table>
                <tbody>
                <tr>
                  <th>Time</th>
                  <th>Program</th>
                </tr>

                    <tr>
                      <td class="time_part"> 0:00 </td>
                      <td class="show_content">
                        <h4>
                          First Up
                        </h4>
                        <p>
                          Bloomberg Television&#39;s award winning morning show takes a look at market openings in Asia and analyzes all the breaking news stories essential for your business day ahead.                        </p>
                      </td>
                    </tr>

                    <tr>
                      <td class="time_part"> 2:00 </td>
                      <td class="show_content">
                        <h4>
                          On the Move with Rishaad Salamat
                        </h4>
                        <p>
                          Rishaad Salamat brings you comprehensive coverage of market openings from Asia and live reporting on the stories most impacting business around the globe.                        </p>
                      </td>
                    </tr>

                    <tr>
                      <td class="time_part"> 4:00 </td>
                      <td class="show_content">
                        <h4>
                          Asia Edge
                        </h4>
                        <p>
                          Get to the bottom of the days major issues influencing business decisions with Rishaad Salamat. Asia Edge gives viewers a deeper perspective through extended interviews with the region&#39;s newsmakers as well as fast-paced panel discussions featuring Bloomberg&#39;s market reporters, business experts and influential guests. Stay ahead of the business day with Asia Edge.                        </p>
                      </td>
                    </tr>
我在代码中做错了什么,一些建议会很好。
问题是当2014年1月20日
我不确定你想用
{'td','h4','p'}
作为第二个参数实现什么。这是一个
集合
,而不是一个
指令
(正如您可能认为的那样)

如果您想获取日期,在这里可以使用一个简单的
soup.find('h3')

>>> print soup.find('h3')
<h3>January 20, 2014</h3>
>>> print soup.find('h3').text
January 20, 2014
>打印soup.find('h3')
2014年1月20日
>>>打印soup.find('h3')。文本
2014年1月20日

是的,这很好,但如果您将日期作为循环,它将不会解析htmlI中的所有标记。我根本无法理解您的最后一句话。对于给定的HTML,您希望输出是什么?
>>> print soup.find('h3')
<h3>January 20, 2014</h3>
>>> print soup.find('h3').text
January 20, 2014