使用 beautifulsoup,如何引用给定表单后的第一个表

发布于 2024-09-11 16:41:58 字数 321 浏览 2 评论 0原文

我想深入研究我的 html,特别是我想获取第一个 html 表,该表位于如下所示的表单之后:

<form method="POST" action="/parts.html">

..

<table ...>
...

</table>

..

</form>

因此,该表对每个产品都有

我的最终目标是循环遍历每个表行,然后我需要提取产品名称、价格、图像网址等。

我的策略应该是什么,以及在 beautiful soup 中我应该关注哪些方法?

I want to drill down into my html, specifically I want to get the first html table that is AFTER a form that looks like:

<form method="POST" action="/parts.html">

..

<table ...>
...

</table>

..

</form>

So this table has <tr> for each product.

My utlimate goal here is to loop through each tablerow, and then I need to extract the product name, price, image url, etc.

What should my strategy be, and what methods in beautiful soup should I be focusing on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文