我使用HTMLParser库来解析html代码。当我覆盖handle_starttag方法时,我只检索带有“root”元素的片段。我需要从表中提取一些链接。我拆分html字符串并尝试解析片段,但结果相同。我尝试解析以下片段:
<td class="lineItemMainInfo" width="100%">
<div class="lineItemGroup">
<div><span class="small productTitle"><strong>
<a rel="nofollow" href="/dp/B007R5YFS4/ref=wl_fv/191-7812654-8275300?_encoding=UTF8&colid=1VII2NY76H4UZ&coliid=I17H6RZSYMY3L1">
Amazon Kindle Paperwhite Leather Cover, Onyx Black (does not fit Kindle or Kindle Touch)
</a>
</strong></span></div>
<div class=lineItemPart style="margin-top: 40px;"><span class=wlPriceBold>$39.99</span></div>
<div style="margin-top: 40px;"><a href="/gp/item-dispatch/ref=cm_wl_addtocart_v/191-7812654-8275300?ie=UTF8&colid=1VII2NY76H4UZ&coliid=I17H6RZSYMY3L1&offeringID.1=XPVNq%252BOcYJUJX1KIbumcWx6ws9PGgJa3gAVhZKZdE0ZWN%252FAq6rL2CoBnw4sUpGte0oDqJjGH15dpME1xUYMI1yg%252BO5y7fw2cpA7RmRZJHNIZw09fS2l4OQ%253D%253D&quantity.1=1&registryID.1=1VII2NY76H4UZ&registryItemID.1=I17H6RZSYMY3L1&session-id=191-7812654-8275300&signInToHUC=0&submit.addToCart=1"><span class="swSprite s_add2CartSm " border="0" vspace="0" hspace="0"style="vertical-align:middle;margin-bottom:2px;" alt="Add to Cart"></span></a></div>
</div>
</td>
我只收到没有任何嵌套标签的td标签。 有人有这个问题吗?