遇到html中的评论,如何停止使用Beautifulsoup提取href标签?

How do I stop extracting href tags using Beautifulsoup when I encounter a comment in html?

    03420&nbsp;&nbsp;<a href="/kegg-bin/show_pathway?ban03420">Nucleotide excision repair</a><br>
    03430&nbsp;&nbsp;<a href="/kegg-bin/show_pathway?ban03430">Mismatch repair</a><br>
    03440&nbsp;&nbsp;<a href="/kegg-bin/show_pathway?ban03440">Homologous recombination</a><br>
      </ul>
    </ul>
    <!-- -->
    <b>Environmental Information Processing</b>
    <ul>
     Membrane transport
      <ul>
    02010&nbsp;&nbsp;<a href="/kegg-bin/show_pathway?ban02010">ABC transporters</a><br>

我需要使用 python 从网页中提取路径代码(例如 03420、03430 等),我已经使用 Beautifulsoup 完成了。我想在环境信息处理之前停下来,所以我在这里寻找一些我可以使用的不同标签。 <!-- --> 处于完美位置,但我无法弄清楚此时如何停止。有人可以告诉我 if/how 我可以用它来停止提取评论前的代码。 (我是 python 和 html 的新手,直接跳转到网络解析,所以请多多包涵。)

HTMLXHTMLXML中,<!--开始评论范围,-->结束评论范围。这是一个评论,它不会影响浏览器的结果,但会在响应中添加一些字节。

<!-- comment some text 
     and you can break lines.
     It is compatible for html, xhtml and xml.
-->

在其他语言上,您有其他的注释语法,例如:

/* this is a comment for C, C++, C#, Java, Javascript, CSS, etc.
   you can break lines */

// this is a single line comment for C, C++, C#, Java, Javascript.. you can't break lines here

如果你想在this link上查看更多关于评论的信息。

这是 html 语法中的块注释。 http://www.w3schools.com/html/html_comments.asp

这是一条 HTML 评论,里面没有任何内容。

就目前而言,它似乎没有任何用途,因为它在页面中没有任何功能,但它的存在可能会引起共鸣。我可能是一些服务器代码显示一些内部信息的地方,所以指望它保持不变有点冒险。

如果它只是一个空评论,页面的作者可能会决定将其清除。

查找以下标记中的文本似乎更可靠,因为它在页面中确实有用。