使用 beautifulsoup,如何引用给定表单后的第一个表
我想深入研究我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
继续阅读。
http://www.crummy.com/software/ BeautifulSoup/documentation.html#Iterating%20over%20a%20Tag
http://www.crummy.com/software/BeautifulSoup/documentation.html#nextSibling%20and%20previousSibling
Keep reading.
http://www.crummy.com/software/BeautifulSoup/documentation.html#Iterating%20over%20a%20Tag
http://www.crummy.com/software/BeautifulSoup/documentation.html#nextSibling%20and%20previousSibling