简体   繁体   中英

fetch tooltip from row

I am trying to fetch tool-tip from table row but it returns None. please look into my code what i tried for this.

<tr onmouseover="this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='DodgerBlue';this.originalcolor=this.style.color;this.style.color='White';Tip('<span Style=Color:Red>License: <BR />20-214767 (Validity: 21/05/2022)<BR />20C-214769 (Validity: 21/05/2022)<BR />21-214768 (Validity: 21/05/2022)</span>');" onmouseout="this.style.backgroundColor=this.originalstyle;this.style.color=this.originalcolor;UnTip();" style="background-color:White;font-family:Times New Roman;font-size:12px;">
        <td style="font-size:10px;font-weight:normal;font-style:normal;text-decoration:none;" align="left">AAYUSH PHARMA</td><td style="font-size:10px;font-weight:normal;font-style:normal;text-decoration:none;" align="left">PUNE-1ST FLOOR, SR.NO.742/A, DINSHOW APARTMENT,,SWAYAM HOSPITAL AND NURSING HOME, BHAWANI PETH</td><td style="font-weight:normal;font-style:normal;text-decoration:none;" align="center">RH - 3</td><td>swapnil ramakant pawar, BPH, [140514-21/04/2017]</td>
</tr> 

want to fetch text of below tool-tip.

Tip('License:
20-214767 (Validity: 21/05/2022)
20C-214769 (Validity: 21/05/2022)
21-214768 (Validity: 21/05/2022)'

Code:

for row in soup.findAll("tr")[1:]:
    licence = row.find("span",{"Style":"Color:Red"})
    print(licence)

Finally I got Required output

for row in soup.findAll("tr")[1:]:
    attr = row.get('onmouseover')
    Attrsoup = BeautifulSoup(attr,   'html.parser')
    print(Attrsoup.span.text)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM