Advertisement

06.02.2006 at 03:14PM PDT, ID: 21873121
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Parse HTML Table

Asked by fakir420 in Python Scripting Language

Tags: , ,

I need example code to parse the following HTML table into a list or array - I'm not sure the best way as I'm new to Python coming from VB.  So far I've been able to get the HTML and split out just the table portion, but I now need to parse the table into (preferrably) a comma delimited list of the tables rows/columns.  I would really like to see and example including parsing out all the unwanted text and just the column headings/column data text.  Also any comments in the code to show me what is going on would help out alot.

Here is the output I'd like to get - this is the first two rows of the table:

Date|Time|From|Duration (hh:mm:ss)
Jun 02, 2006|02:53 PM|13012684637|00:01:00


<---------------Start Table--------------->      
        <table width="100%" id="received_calls" border="0" cellpadding="1" cellspacing="2">
                        <tr class="tableheader2">
                              <td align=left colspan=5 class="tableheader2">Received Calls</td>
                </tr>
               
                           
                            <tr>
                                <TD nowrap class="tableheader9" width="20%" >Date</TD>
                                <TD nowrap class="tableheader9" width="20%" >Time</TD>
                             
                                       <TD nowrap class="tableheader9" width="35%" >
                                               <div class="iconButton"></div><div class="iconButton"></div>From</TD>
                               
                                <TD nowrap class="tableheader9" width="25%" >Duration (hh:mm:ss)</TD>
                            </tr>
                           
                            <tr class="tablebody1">
                               
                               
                               
                                <TD nowrap >Jun 02, 2006&nbsp;</TD>
                                <TD nowrap >03:56 PM&nbsp;</TD>
                           
                                    <TD nowrap ><!-- forward call setion -->
                                         

                                         <!--  from caller setion -->

                                           
                                      <div class="iconButton"><a href="javascript:void(0)" onclick="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', STICKY, CSSCLASS);" onmouseover="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', CSSCLASS);" onmouseout="return nd();"><img src="/static/common-web/images/activity_icons/icon_caller_id.gif" border="0" ></a></div>

                                         <div class="iconButton"><img src="/static/common-web/images/activity_icons/icon_filler.gif" border="0" ></div>
                                             
                                          <div class="phoneNumber">13012684637</div>
                                    </TD>
                               
                                    <TD nowrap >
                                                 00:02:00</TD>
                            </tr>
                           
                            <tr >
                               
                               
                               
                                <TD nowrap >Jun 02, 2006&nbsp;</TD>
                                <TD nowrap >02:53 PM&nbsp;</TD>
                           
                                    <TD nowrap ><!-- forward call setion -->
                                         

                                         <!--  from caller setion -->

                                           
                                      <div class="iconButton"><a href="javascript:void(0)" onclick="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', STICKY, CSSCLASS);" onmouseover="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', CSSCLASS);" onmouseout="return nd();"><img src="/static/common-web/images/activity_icons/icon_caller_id.gif" border="0" ></a></div>

                                         <div class="iconButton"><img src="/static/common-web/images/activity_icons/icon_filler.gif" border="0" ></div>
                                             
                                          <div class="phoneNumber">13012684637</div>
                                    </TD>
                               
                                    <TD nowrap >
                                                 00:01:00</TD>
                            </tr>
                           
                            <tr class="tablebody1">
                               
                               
                               
                                <TD nowrap >Jun 02, 2006&nbsp;</TD>
                                <TD nowrap >12:29 PM&nbsp;</TD>
                           
                                    <TD nowrap ><!-- forward call setion -->
                                         

                                         <!--  from caller setion -->

                                           
                                      <div class="iconButton"><a href="javascript:void(0)" onclick="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', STICKY, CSSCLASS);" onmouseover="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', CSSCLASS);" onmouseout="return nd();"><img src="/static/common-web/images/activity_icons/icon_caller_id.gif" border="0" ></a></div>

                                         <div class="iconButton"><img src="/static/common-web/images/activity_icons/icon_filler.gif" border="0" ></div>
                                             
                                          <div class="phoneNumber">13012684637</div>
                                    </TD>
                               
                                    <TD nowrap >
                                                 00:01:00</TD>
                            </tr>
                           
                            <tr >
                               
                               
                               
                                <TD nowrap >Jun 02, 2006&nbsp;</TD>
                                <TD nowrap >11:55 AM&nbsp;</TD>
                           
                                    <TD nowrap ><!-- forward call setion -->
                                         

                                         <!--  from caller setion -->

                                           
                                      <div class="iconButton"><a href="javascript:void(0)" onclick="return overlib('<CENTER>15408774179<br><br><b>PCS PHONE    VA</b>', STICKY, CSSCLASS);" onmouseover="return overlib('<CENTER>15408774179<br><br><b>PCS PHONE    VA</b>', CSSCLASS);" onmouseout="return nd();"><img src="/static/common-web/images/activity_icons/icon_caller_id.gif" border="0" ></a></div>

                                         <div class="iconButton"><img src="/static/common-web/images/activity_icons/icon_filler.gif" border="0" ></div>
                                             
                                          <div class="phoneNumber">15408774179</div>
                                    </TD>
                               
                                    <TD nowrap >
                                                 00:06:00</TD>
                            </tr>
                           
                            <tr class="tablebody1">
                               
                               
                               
                                <TD nowrap >Jun 02, 2006&nbsp;</TD>
                                <TD nowrap >11:41 AM&nbsp;</TD>
                           
                                    <TD nowrap ><!-- forward call setion -->
                                         

                                         <!--  from caller setion -->

                                           
                                      <div class="iconButton"><a href="javascript:void(0)" onclick="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', STICKY, CSSCLASS);" onmouseover="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', CSSCLASS);" onmouseout="return nd();"><img src="/static/common-web/images/activity_icons/icon_caller_id.gif" border="0" ></a></div>

                                         <div class="iconButton"><img src="/static/common-web/images/activity_icons/icon_filler.gif" border="0" ></div>
                                             
                                          <div class="phoneNumber">13012684637</div>
                                    </TD>
                               
                                    <TD nowrap >
                                                 00:01:00</TD>
                            </tr>
                           
                            <tr >
                               
                               
                               
                                <TD nowrap >Jun 02, 2006&nbsp;</TD>
                                <TD nowrap >11:41 AM&nbsp;</TD>
                           
                                    <TD nowrap ><!-- forward call setion -->
                                         

                                         <!--  from caller setion -->

                                           
                                      <div class="iconButton"><a href="javascript:void(0)" onclick="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', STICKY, CSSCLASS);" onmouseover="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', CSSCLASS);" onmouseout="return nd();"><img src="/static/common-web/images/activity_icons/icon_caller_id.gif" border="0" ></a></div>

                                         <div class="iconButton"><img src="/static/common-web/images/activity_icons/icon_filler.gif" border="0" ></div>
                                             
                                          <div class="phoneNumber">13012684637</div>
                                    </TD>
                               
                                    <TD nowrap >
                                                 00:01:00</TD>
                            </tr>
                           
                            <tr class="tablebody1">
                               
                               
                               
                                <TD nowrap >Jun 02, 2006&nbsp;</TD>
                                <TD nowrap >11:40 AM&nbsp;</TD>
                           
                                    <TD nowrap ><!-- forward call setion -->
                                         

                                         <!--  from caller setion -->

                                           
                                      <div class="iconButton"><a href="javascript:void(0)" onclick="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', STICKY, CSSCLASS);" onmouseover="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', CSSCLASS);" onmouseout="return nd();"><img src="/static/common-web/images/activity_icons/icon_caller_id.gif" border="0" ></a></div>

                                         <div class="iconButton"><img src="/static/common-web/images/activity_icons/icon_filler.gif" border="0" ></div>
                                             
                                          <div class="phoneNumber">13012684637</div>
                                    </TD>
                               
                                    <TD nowrap >
                                                 00:01:00</TD>
                            </tr>
                           
                            <tr >
                               
                               
                               
                                <TD nowrap >Jun 01, 2006&nbsp;</TD>
                                <TD nowrap >05:49 PM&nbsp;</TD>
                           
                                    <TD nowrap ><!-- forward call setion -->
                                         

                                         <!--  from caller setion -->

                                           
                                      <div class="iconButton"><a href="javascript:void(0)" onclick="return overlib('<CENTER>18666894118<br><br><b>800 SERVICE</b>', STICKY, CSSCLASS);" onmouseover="return overlib('<CENTER>18666894118<br><br><b>800 SERVICE</b>', CSSCLASS);" onmouseout="return nd();"><img src="/static/common-web/images/activity_icons/icon_caller_id.gif" border="0" ></a></div>

                                         <div class="iconButton"><img src="/static/common-web/images/activity_icons/icon_filler.gif" border="0" ></div>
                                             
                                          <div class="phoneNumber">18666894118</div>
                                    </TD>
                               
                                    <TD nowrap >
                                                 00:01:00</TD>
                            </tr>
                           
                            <tr class="tablebody1">
                               
                               
                               
                                <TD nowrap >Jun 01, 2006&nbsp;</TD>
                                <TD nowrap >04:48 PM&nbsp;</TD>
                           
                                    <TD nowrap ><!-- forward call setion -->
                                         

                                         <!--  from caller setion -->

                                           
                                      <div class="iconButton"><a href="javascript:void(0)" onclick="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', STICKY, CSSCLASS);" onmouseover="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', CSSCLASS);" onmouseout="return nd();"><img src="/static/common-web/images/activity_icons/icon_caller_id.gif" border="0" ></a></div>

                                         <div class="iconButton"><img src="/static/common-web/images/activity_icons/icon_filler.gif" border="0" ></div>
                                             
                                          <div class="phoneNumber">13012684637</div>
                                    </TD>
                               
                                    <TD nowrap >
                                                 00:01:00</TD>
                            </tr>
                           
                            <tr >
                               
                               
                               
                                <TD nowrap >Jun 01, 2006&nbsp;</TD>
                                <TD nowrap >04:48 PM&nbsp;</TD>
                           
                                    <TD nowrap ><!-- forward call setion -->
                                         

                                         <!--  from caller setion -->

                                           
                                      <div class="iconButton"><a href="javascript:void(0)" onclick="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', STICKY, CSSCLASS);" onmouseover="return overlib('<CENTER>13012684637<br><br><b>CELL PHONE   MD</b>', CSSCLASS);" onmouseout="return nd();"><img src="/static/common-web/images/activity_icons/icon_caller_id.gif" border="0" ></a></div>

                                         <div class="iconButton"><img src="/static/common-web/images/activity_icons/icon_filler.gif" border="0" ></div>
                                             
                                          <div class="phoneNumber">13012684637</div>
                                    </TD>
                               
                                    <TD nowrap >
                                                 00:01:00</TD>
                            </tr>
                           
                           

                           
                       
                  </table>
<---------------End Table--------------->Start Free Trial
 
Loading Advertisement...
 
[+][-]06.02.2006 at 03:16PM PDT, ID: 16820734

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.02.2006 at 03:52PM PDT, ID: 16820917

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Python Scripting Language
Tags: html, table, parse
Sign Up Now!
Solution Provided By: RichieHindle
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.02.2006 at 04:12PM PDT, ID: 16821039

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43