爬取https://sailboatdata.com/sailboat
时间: 2023-10-12 20:09:31 浏览: 77
对话模式下无法进行爬取操作,以下是示例代码:
```python
import requests
from bs4 import BeautifulSoup
url = 'https://sailboatdata.com/sailboat'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# 获取所有的船名
boat_names = [name.text for name in soup.select('.sailboat-name > a')]
print(boat_names)
# 获取所有的船型
boat_types = [type.text for type in soup.select('.sailboat-type')]
print(boat_types)
# 获取所有的船长度
boat_lengths = [length.text for length in soup.select('.sailboat-length')]
print(boat_lengths)
```
阅读全文