weixin_41098099
2020-04-22 23:08
采纳率: 100%
浏览 958

关于python爬取获取标签内的值

<div class="price_d">
                <p class="t">
                    <span id="dd-price-text">当当价</span>
                    <a class="price_down_remind score write_comment" href="javascript:void(0);" id="price_down">降价通知</a>
                </p>
                <p id="dd-price">
                    <span class="yen">¥</span>89.00                
                                </p>
</div>

请问第二个P标签里面的89怎么通过python取出来?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • little student 2020-04-23 11:22
    已采纳

    假设 c = 上边那些字符

    c = '''<div class="price_d">
                    <p class="t">
                        <span id="dd-price-text">当当价</span>
                        <a class="price_down_remind score write_comment" href="javascript:void(0);" id="price_down">降价通知</a>
                    </p>
                    <p id="dd-price">
                        <span class="yen">¥</span>89.00                
                                    </p>
    </div>'''
    
    import re
    r = re.findall(r"¥</span>(\d+\.?\d*)",c,re.S)
    
    3 打赏 评论

相关推荐 更多相似问题