this is the tag im looking to find with the below regex '<span itemprop="price">34.97</span>'
matches = re.findall(r'<span itemprop="price">\$(\d+)</span>', html)
以上只是尝试过,如果没有$
我希望在这个例子中看到价格34.97,但是当我运行代码时,这里是返回的值(没有返回结果)
最高价格:$ 0最低价格:$ 0 200 []
你试图捕获34.97
\ d +不占美元和美分之间的时间。
尝试:(\ d +。\ d +)
\d+ (one or more digit)
\. (escaped . character so it captures one period)
\d+ (one or more digits)
是你的朋友!
上面的选项和建议都有用,但经过一些测试后我们发现有些情况下标签中没有数值,因此选择了最后一个建议([^ <] +)
这似乎现在抓住了这些情况,并将根据需要进行调整。我们正在构建一个概念蜘蛛,所以这将用于我们的测试和演示功能。