<font class="detDesc">Uploaded 10-29 18:50, Size 4.36 GiB, ULed by <a class="detDesc" href="/user/NLUPPER002/" title="Browse NLUPPER002">NLUPPER002</a></font>
我需要 上传了10-29 18:50,大小4.36 GiB和NLUPPER002在两个单独的阵列中。我该怎么做?在
编辑:
这是一个html页面的一部分,它有许多具有不同值的html字体标记。我需要一个通用的解决方案,如果有的话,用汤。否则,正如建议的那样,我将研究regex。在
编辑2:
我对此有疑问。如果我们使用“class”作为键来遍历一个soup,它不会用python关键字类来类并抛出一个错误吗?在
查找感兴趣的元素所需的表达式取决于这些元素与文档中其他元素相比的唯一性。因此,如果没有元素的上下文,就很难提供帮助。在
您感兴趣的元素是文档中唯一的
font
元素并且具有detDesc
类的元素吗?在如果是这样,下面是一个使用^{} 的解决方案:
结果:
^{pr2}$例如,使用以下数据:
^{pr2}$运行上面的代码可以得到:
要获得与前面提到的格式完全相同的文本,可以对列表进行后处理,也可以在循环本身中解析数据。例如:
另外,如果你是列表理解的粉丝,那么解决方案可以用一句话来表达:
这将为您提供:
相关问题 更多 >
编程相关推荐