Matching partial ids in BeautifulSoup

前端 未结 4 524
一整个雨季
一整个雨季 2020-11-29 07:21

I\'m using BeautifulSoup. I have to find any reference to the

tags with id like: post-#.

For example:

4条回答
  •  伪装坚强ぢ
    2020-11-29 07:52

    Since he is asking to match "post-#somenumber#", it's better to precise with

    import re
    [...]
    soupHandler.findAll('div', id=re.compile("^post-\d+"))
    

提交回复
热议问题