首先,你需要安装Python库'beautifulsoup4'和'requests',如果没有安装过,你可以在终端中使用'pip install beautifulsoup4'和'pip install requests'来安装。
然后你可以使用以下代码来爬取这个数据集:
import requests
from bs4 import BeautifulSoup
url ="https://www.kaggle.com/datasets/sudhanshu2198/oil-spill-detection"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
download_url = soup.find_all("a", class_="gs-c-btn gs-c-btn--small gs-c-btn--primary gs-c-btn--inline")[0]["href"]
print(download_url)

本文介绍了如何使用Python的beautifulsoup4和requests库爬取Kaggle网站上的石油泄漏检测数据集。首先确保安装所需库,接着通过示例代码演示爬取过程。
最低0.47元/天 解锁文章
993

被折叠的 条评论
为什么被折叠?



