大家好!
我觉得在bs4 find_all multiple中,使用一个自定义函数也很有用。
你可以传递一个函数给 `find_all`,这样可以根据条件灵活筛选元素。例如:
```python
def match_class(elem):
return 'class1' in elem.get('class', []) or 'class2' in elem.get('class', [])
soup.find_all(match_class)
```
我觉得在bs4 find_all multiple中,使用一个自定义函数也很有用。
你可以传递一个函数给 `find_all`,这样可以根据条件灵活筛选元素。例如:
```python
def match_class(elem):
return 'class1' in elem.get('class', []) or 'class2' in elem.get('class', [])
soup.find_all(match_class)
```
