How I do get the data from the <font> tag from a given tr tag?

0 votes
<tr id="tr_m_1570:240HJY" class="flavored_option_display_enabled">
    <td width="1" height="1" valign="Top"><img src="https://si.cdn.abc.com/images/global/configurator/general/spacer.gif" border="0" height="1" width="1"></td>
    <td width="100%">
        <table name="t_m_1570:240HJY" id="t_m_1570:240HJY" cellpadding="0" cellspacing="0" border="0" width="100%">
            <tbody>
                <tr>
                    <td width="9" height="1" valign="Top"><img src="https://si.cdn.abc.com/images/global/configurator/general/spacer.gif" border="0" height="1" width="9"></td>
                    <td valign="top">
                        <a name="m_1570:240HJY" id="m_1570:240HJY"></a>
                        <input type="checkbox" onmousedown="validateMouseDown(event);" onkeydown="validateKeyDown(event);" onclick="tealeafAddEvent(this, 'custom_checkbox_click','m_1570_240HJY'); checkOnClick(event), enableQtyText('m_1570','240HJY','true');" id="m_1570" name="m_1570" displayname="m_1570_240HJY" value="240HJY">
                    </td>
                    <td width="100%" style="line-break:strict;word-break:keep-all;line-height:2">
                        <div>
                            <span id="sq_m_1570_240HJY" style="display:inline" ;=""><input type="text" id="q_m_1570:240HJY" name="q_m_1570:240HJY" size="1" class="qty_text_box_set" onkeyup="showQtyUpdateButton('sqb_m_1570_240HJY')" value="1" onfocus="javascript:enableQtyText('m_1570','240HJY','false');"></span>
                            <span id="sqb_m_1570_240HJY" style="display:none" ;=""><input type="button" id="qb_m_1570_240HJY" name="qb_m_1570_240HJY" size="2" style="font-size:10px" value="Update" onclick="updateOptionQty('q_m_1570:240HJY','m_1570','240HJY')"></span>
                            <font size="1">&nbsp;240GB Solid State Drive SATA Read Intensive 6Gbps 512 2.5in Hot-plug Boot 3.5 HYB CARR&nbsp;<span id="op_m_1570:240HJY" name="op_m_1570:240HJY">[£318.00&nbsp;or&nbsp;£12/month<sup>-1</sup>]</span></font>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
        <!--option1 close-->
    </td>
</tr>

I want to get the texr from the font tag.

Sep 17 in Python by Himanshu
• 120 points

edited Sep 18 by Omkar 47 views

1 answer to this question.

0 votes

This should work:

from bs4 import BeautifulSoup

html_doc='''<tr id="tr_m_1570:240HJY" class="flavored_option_display_enabled">
    <td width="1" height="1" valign="Top"><img src="https://si.cdn.abc.com/images/global/configurator/general/spacer.gif" border="0" height="1" width="1"></td>
    <td width="100%">
        <table name="t_m_1570:240HJY" id="t_m_1570:240HJY" cellpadding="0" cellspacing="0" border="0" width="100%">
            <tbody>
                <tr>
                    <td width="9" height="1" valign="Top"><img src="https://si.cdn.abc.com/images/global/configurator/general/spacer.gif" border="0" height="1" width="9"></td>
                    <td valign="top">
                        <a name="m_1570:240HJY" id="m_1570:240HJY"></a>
                        <input type="checkbox" onmousedown="validateMouseDown(event);" onkeydown="validateKeyDown(event);" onclick="tealeafAddEvent(this, 'custom_checkbox_click','m_1570_240HJY'); checkOnClick(event), enableQtyText('m_1570','240HJY','true');" id="m_1570" name="m_1570" displayname="m_1570_240HJY" value="240HJY">
                    </td>
                    <td width="100%" style="line-break:strict;word-break:keep-all;line-height:2">
                        <div>
                            <span id="sq_m_1570_240HJY" style="display:inline" ;=""><input type="text" id="q_m_1570:240HJY" name="q_m_1570:240HJY" size="1" class="qty_text_box_set" onkeyup="showQtyUpdateButton('sqb_m_1570_240HJY')" value="1" onfocus="javascript:enableQtyText('m_1570','240HJY','false');"></span>
                            <span id="sqb_m_1570_240HJY" style="display:none" ;=""><input type="button" id="qb_m_1570_240HJY" name="qb_m_1570_240HJY" size="2" style="font-size:10px" value="Update" onclick="updateOptionQty('q_m_1570:240HJY','m_1570','240HJY')"></span>
                            <font size="1">&nbsp;240GB Solid State Drive SATA Read Intensive 6Gbps 512 2.5in Hot-plug Boot 3.5 HYB CARR&nbsp;<span id="op_m_1570:240HJY" name="op_m_1570:240HJY">[£318.00&nbsp;or&nbsp;£12/month<sup>-1</sup>]</span></font>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
        <!--option1 close-->
    </td>
</tr>'''

soup = BeautifulSoup(html_doc, 'html.parser')

print(soup.font.text)
answered Sep 18 by Omkar
• 68,480 points

Related Questions In Python

0 votes
1 answer
+1 vote
1 answer

how do i get a optimal cutoff value(directly in the form of numeric) from roc curves?

The optimal CutOff value is the point ...READ MORE

answered Oct 17 in Python by Saira
129 views
0 votes
1 answer
0 votes
1 answer

In NumPy how do I get the maximum of subsets? Python

You can use np.maximum.reduceat: >>> _, idx = np.unique(g, ...READ MORE

answered Nov 9, 2018 in Python by Nymeria
• 3,520 points
88 views
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8 in Selenium by Anvi
• 13,960 points
283 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,430 points
1,193 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,510 points
1,278 views
0 votes
1 answer
0 votes
1 answer

How to print a message or the error if a file is not found?

To print the message that file is not ...READ MORE

answered Jan 2 in Python by Omkar
• 68,480 points
45 views