"如何在bs4中使用find_all multiple来提取数据?"

8 Replies, 311 Views

嗨,大家!

我在使用bs4 find_all multiple时,发现可以用 `attrs` 参数来处理多个条件。

例如,如果你想提取特定类名和其他属性的元素,可以这样写:

```python
soup.find_all('div', class_='class1', attrs={'data-attribute': 'value'})
```

这样能更精确地提取你需要的元素。

Messages In This Thread



Users browsing this thread: 1 Guest(s)