بنقرة واحدة
web-scraping
网页抓取与数据提取。Use when (1) 需要抓取网页内容, (2) 绕过反爬虫机制, (3) 处理动态加载内容, (4) 批量采集数据, (5) 解析特定网站结构
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
网页抓取与数据提取。Use when (1) 需要抓取网页内容, (2) 绕过反爬虫机制, (3) 处理动态加载内容, (4) 批量采集数据, (5) 解析特定网站结构
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
PPTX to Markdown 转换。Use when (1) 将 .pptx 转换为 .md, (2) 提取 PPT 内容和截图, (3) 需求文档/修改事项 PPTX 解析, (4) 包含标注截图的 PPTX 处理, (5) 批量转换演示文稿
专业的AI Agent(AI Agents)顾问助手,探索 AI Agent 框架和应用。当用户询问以下问题时使用:(1) 技术选型和对比 (2) 使用指南和最佳实践 (3) 问题诊断和解决 (4) 资源推荐 (5) 常见问题解答
Comprehensive CV learning assistant. Use when studying image processing, object detection, segmentation, or any CV tasks. Helps with algorithm understanding, implementation, and model optimization.
Comprehensive DL learning assistant. Use when studying neural networks, CNN, RNN, LSTM, Transformer, or any DL architectures. Helps with network design, training strategies, debugging, and optimization techniques.
Comprehensive LLM learning assistant. Use when studying transformer architecture, attention mechanisms, pre-training, fine-tuning, or prompt engineering. Helps with understanding LLM principles and practical applications.
Comprehensive ML learning assistant. Use when studying supervised learning, unsupervised learning, regression, classification, clustering, or any ML concepts. Helps with algorithm understanding, implementation guidance, model evaluation, and practical applications.
| name | web-scraping |
| description | 网页抓取与数据提取。Use when (1) 需要抓取网页内容, (2) 绕过反爬虫机制, (3) 处理动态加载内容, (4) 批量采集数据, (5) 解析特定网站结构 |
Always use stealth configuration to avoid detection:
# Remove automation flags
context.add_init_script("""
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined
});
""")
# Use realistic settings
browser = playwright.chromium.launch(
args=['--disable-blink-features=AutomationControlled']
)
Add random delays and smooth interactions:
import random
await asyncio.sleep(random.uniform(0.5, 2.0))
await page.mouse.move(x, y, steps=random.randint(10, 30))
Use appropriate wait strategies:
# For static content
await page.goto(url, wait_until='networkidle')
# For dynamic content
await page.wait_for_selector('.content')
await page.wait_for_function("document.querySelectorAll('.item').length > 10")
title = await page.locator('h1').first.text_content()
paragraphs = await page.locator('article p').all_text_contents()
content = '\n\n'.join(paragraphs)
while len(items) < max_items:
await page.evaluate("window.scrollTo(0, document.body.scrollHeight)")
await page.wait_for_timeout(2000)
current_items = await page.locator('.item').all()
if len(current_items) == previous_count:
break
# Close cookie banners and modals
try:
await page.click('button:has-text("Accept")', timeout=3000)
except:
pass
await page.fill('input[name="username"]', username)
await page.fill('input[name="password"]', password)
await page.click('button[type="submit"]')
await page.wait_for_url('**/dashboard')
cookies = await context.cookies() # Save for reuse
Implement rate limiting to avoid bans:
from tenacity import retry, stop_after_attempt, wait_exponential
@retry(stop=stop_after_attempt(3), wait=wait_exponential(min=4, max=10))
async def scrape_with_retry(url: str):
# Your scraping logic
pass
Track requests per time window:
class RateLimiter:
def __init__(self, max_requests: int, time_window: int):
self.max_requests = max_requests
self.time_window = time_window
self.requests = []
async def wait_if_needed(self):
# Remove old requests, wait if limit reached
pass
Use BeautifulSoup for parsing after Playwright renders:
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'lxml')
# Remove unwanted elements
for element in soup(['script', 'style', 'nav', 'footer']):
element.decompose()
# Extract structured data
article = soup.find('article') or soup.find('main')
paragraphs = [p.get_text(strip=True) for p in article.find_all('p')]
Cache results to minimize requests:
import hashlib
import json
def get_cache_path(url: str) -> Path:
url_hash = hashlib.md5(url.encode()).hexdigest()
return Path(f'.cache/{url_hash}.json')
# Check cache before scraping
cached = load_from_cache(url)
if cached:
return cached
pip install playwright beautifulsoup4 lxml tenacity
playwright install chromium
# Or with uv
uv add playwright beautifulsoup4 lxml tenacity
uv run playwright install chromium
scripts/scrapers/
├── base.py # Base scraper class with stealth mode
├── extractors/ # Site-specific extractors
│ ├── medium.py
│ ├── github.py
│ └── generic.py
├── utils/
│ ├── stealth.py # Anti-bot utilities
│ ├── cache.py # Caching logic
│ └── rate_limit.py # Rate limiting
└── config.py # User agents, timeouts, etc.
Before deploying:
playwright install chromiumwait_until='domcontentloaded'wait_for_selector()For detailed code examples: See references/examples.md
For site-specific patterns: See references/patterns.md
For advanced anti-bot techniques: See references/stealth-guide.md