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 18, 2019 in Python by Himanshu
• 120 points

edited Sep 18, 2019 by Omkar 881 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, 2019 by Omkar
• 69,220 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, 2019 in Python by Saira
3,373 views
0 votes
1 answer

How do I trim the leading or trailing zeros from a 1d array in python?

Hey @Akki, you can use the numpy ...READ MORE

answered May 29, 2019 in Python by Wakir
1,739 views
0 votes
1 answer

Installing Selenium Webdriver with Python package

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

answered May 8, 2019 in Selenium by Anvi
• 14,150 points
15,880 views
0 votes
2 answers

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,500 points
13,764 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,184 views
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,910 points
7,258 views
–1 vote
2 answers
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, 2019 in Python by Omkar
• 69,220 points
2,903 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP