Troubleshooting Computer Issues
用于系统性诊断和解决软件配置、安装错误及运行异常等问题。
下载 123
支持反爬虫、多页爬取的Python网页数据提取技能。
openclaw skills install @sea2049/sea2049-scrapling-skill命令、参数、文件名以原文为准
使用 Scrapling 提取网页数据,实现最小化选择器失效,并具备更强的反机器人防护能力。
在用户提出以下需求时优先使用本技能:
开始抓取前,请始终:
所有依赖项应安装在 D:\clawtest 目录下。
推荐的设置命令如下:
python -m venv D:\clawtest\.venv
D:\clawtest\.venv\Scripts\python -m pip install -U pip
D:\clawtest\.venv\Scripts\python -m pip install "scrapling[fetchers]"
D:\clawtest\.venv\Scripts\scrapling install说明:
pip install scrapling 即可。scrapling install。选择最轻量且能满足需求的选项:
Fetcher:- 适用于静态页面,追求速度。
StealthyFetcher:- 当目标站点可能存在反机器人检测时,作为默认首选。
DynamicFetcher:- 当数据由 JavaScript 渲染时使用。
Spider:- 用于多页面爬取、任务队列、并发处理及结构化导出。
Fetcher → StealthyFetcher → DynamicFetcher)。from scrapling.fetchers import StealthyFetcher
StealthyFetcher.adaptive = True
url = "https://example.com/products"
page = StealthyFetcher.fetch(url, headless=True, network_idle=True, timeout=45000)
items = []
for card in page.css(".product-card", auto_save=True):
items.append({
"title": card.css("h2::text").get(default="").strip(),
"price": card.css(".price::text").get(default="").strip(),
"url": card.css("a::attr(href)").get(default="")
})
print(items)# 第一次运行时保存指纹:
products = page.css(".product-card", auto_save=True)
# 后续运行可在布局变动后自动恢复:
products = page.css(".product-card", adaptive=True)from scrapling.spiders import Spider, Response
class ProductSpider(Spider):
name = "product_spider"
start_urls = ["https://example.com/catalog"]
async def parse(self, response: Response):
for card in response.css(".product-card"):
yield {
"title": card.css("h2::text").get(default="").strip(),
"price": card.css(".price::text").get(default="").strip(),
}
for href in response.css("a.next::attr(href)").all():
yield response.follow(href, callback=self.parse)
if __name__ == "__main__":
ProductSpider().start()当使用此技能执行用户任务时,应返回:
若数据提取失败,请按以下顺序尝试:
Fetcher 切换至 StealthyFetcher;DynamicFetcher;auto_save=True,再启用 adaptive=True);已收录 1 个 Skill