<dd class="gray6">
<span class="gray6">
中文
<span class="padl27"></span>
中文
</span>
中文内容 #需要抓取的内容
</dd>
用BeautifulSoup html.parser解析的网页,现在用re模块想抓取**第7行**的中文内容,放在一个组里面(.*?)。正则老是匹配不上,用换行符也匹配不上,不知道怎么写了。。。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
既然你都用bs4解析了,为什么不用它提取哪?
bs4内有一个stripped_string的函数正好满足你的需要。
这样可以不?