Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python从HTML标记中检索属性值_Html_Python 3.x_Beautifulsoup - Fatal编程技术网

使用python从HTML标记中检索属性值

使用python从HTML标记中检索属性值,html,python-3.x,beautifulsoup,Html,Python 3.x,Beautifulsoup,我试图从HTML页面的所有字体标记中仅检索属性值。HTML内容(许多字体标记之一)如下所示: <tr> <td align="left" valign="top">&#546;</td> <td> <a href="space.xml" target="Dest"> &l

我试图从HTML页面的所有字体标记中仅检索属性值。HTML内容(许多字体标记之一)如下所示:

<tr>
    <td align="left" valign="top">&#546;</td>
        <td>
            <a href="space.xml" target="Dest">
                <FONT COLOR="#0000FF">Start</FONT>
            </a>
        </td>
</tr>
任何帮助都将不胜感激。
提前感谢

您可以这样做:

trs = soup_file.select("[COLOR]")
print(trs)
soup_file = BeautifulSoup(above_html_string, "html.parser")
color = soup_file.find("font").attrs["color"]
我会给你

'#0000FF'

您可以这样做:

trs = soup_file.select("[COLOR]")
print(trs)
soup_file = BeautifulSoup(above_html_string, "html.parser")
color = soup_file.find("font").attrs["color"]
我会给你

'#0000FF'

问题解决了吗?如果是,请将任何答案标记为已接受。问题是否已解决?如果是,请将任何答案标记为已接受。