pythonweb-scrapingbeautifulsoup

how to extract text within font tag using beautifulsoup


I am making my first program with beautifulsoup and my html file has code snippet like this

......
......
......

<font face="verdana" size="3">5 n i D 1 C</font>
......
......

I want to extract 5 n i D 1 C from within the <font> tag. I am doing

ele=soup('font', face="verdana",size="3") then

ele.Contents()

but i am getting an error AttributeError: 'ResultSet' object has no attribute 'font' when i do

 print ele

output is

[<font face="verdana" size="3">5 n i D 1 C</font>]

that means it is searching correctly, please help me how to extract the given text.

Thank you


Solution

  • ele[0].contents[0]
    u'5 n i D 1 C'