用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/publisher-skill/claude-skill --skill web-crawler命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | web-crawler |
| description | 基于requests和BeautifulSoup的网页爬虫skill,支持抓取网页内容、提取链接、下载图片等功能 |
| metadata | {"type":"custom"} |
一个功能强大的网页爬虫工具,基于requests和BeautifulSoup4构建。
from claude_skills.web_crawler import WebCrawler
# 创建爬虫实例
crawler = WebCrawler()
# 抓取网页
html = crawler.fetch("https://example.com")
# 提取所有链接
links = crawler.extract_links(html)
# 下载图片
crawler.download_image("https://example.com/image.jpg", "output/image.jpg")
# 使用CSS选择器提取内容
titles = crawler.select(html, "h1.title")
# 自定义请求头
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
}
crawler = WebCrawler(headers=headers, timeout=30)
__init__(headers=None, timeout=10)初始化爬虫实例。
参数:
headers (dict, optional): 自定义HTTP请求头timeout (int, optional): 请求超时时间(秒)fetch(url, params=None)获取网页HTML内容。
参数:
url (str): 目标URLparams (dict, optional): URL查询参数返回:
str: HTML内容extract_links(html, base_url=None)从HTML中提取所有链接。
参数:
html (str): HTML内容base_url (str, optional): 基础URL,用于补全相对链接返回:
list: 链接列表extract_text(html)从HTML中提取纯文本内容。
参数:
html (str): HTML内容返回:
str: 纯文本内容select(html, selector)使用CSS选择器提取元素。
参数:
html (str): HTML内容selector (str): CSS选择器返回:
list: 匹配的元素文本列表download_image(url, save_path)下载图片到本地。
参数:
url (str): 图片URLsave_path (str): 保存路径get_soup(html)获取BeautifulSoup对象,进行更复杂的解析。
参数:
html (str): HTML内容返回:
BeautifulSoup: Soup对象