http-response-handling
できること
このスキルは、ブラウザ風のリクエストでウェブページをダウンロードし、サイトが空のプレースホルダーを返したときを見分ける方法を示します。JavaScriptで内容を読み込むウェブサイトから情報を集める人向けです。
使う場面
- ✓JavaScriptで内容が読み込まれるため、ウェブページの文字がほとんどないとき。
- ✓単純な自動化されたリクエストには、サイトが違う内容を返すとき。
- ✓ダウンロードしたページに、必要な情報が本当に含まれているかを確認したいとき。
スキルのリンク
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/http-response-handling/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私が読みたいウェブサイトが、AIには空のページに見えています。ブラウザのように取得して、内容が本当にあるかを教えてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
AIは、ブラウザ風のヘッダーを付けてcurlでページを取得し、ファイルのサイズを確認し、読み込み中の文言やnoscriptタグなどの目印を探して、実際の内容とプレースホルダーを見分けます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
HTTP Response Handling for JavaScript-Dependent Sites
When to Use This Skill
Use this technique when you need to fetch content from websites that:
- Render content dynamically with JavaScript
- Return placeholder HTML when accessed by non-browser clients
- Deliver different content based on User-Agent headers
Core Technique
Step 1: Fetch Content with Browser-Like Headers
Use curl with a realistic User-Agent header to mimic a real browser:
curl -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" -o output.html "https://example.com"
Key flags:
-L— Follow redirects-A— Set User-Agent header to mimic a real browser-o— Save output to file for inspection
Step 2: Detect Placeholder HTML Responses
After fetching, check if you received a placeholder response instead of actual content:
# Check file size (placeholder responses are often very small)
wc -c output.html
# Check for common placeholder indicators
grep -i "javascript" output.html | head -5
grep -i "loading" output.html | head -5
grep -i "noscript" output.html | head -5
Signs of a placeholder response:
- File size is suspiciously small (<5KB for content pages)
- Contains大量 JavaScript but minimal actual content
- Has "loading", "spinner", or "noscript" tags
- Missing expected text/data from the page
Step 3: Validate File Type Before Parsing
Before attempting format-specific parsing, validate the file type:
# Check the file type
file output.html
# Check the actual content type (if you have the headers)
curl -I -A "Mozilla/5.0 ..." "https://example.com" | grep -i content-type
# Inspect first few lines
head -50 output.html
Common checks:
- HTML files: Should start with
<!DOCTYPEor<html - JSON files: Should start with
{or[ - PDF files: Should start with
%PDF - Empty/error pages: May contain error messages or generic HTML
Step 4: Handle Different Scenarios
If you got valid HTML content:
# Proceed with HTML parsing or extraction
grep -oP '(?<=<title>).*?(?=</title>)' output.html
If you got a placeholder/JS-dependent response:
- Option A: Use a headless browser (Playwright, Selenium)
- Option B: Look for an API endpoint that returns JSON directly
- Option C: Check if the site has a mobile/API version with simpler responses
If you got an unexpected file type:
# Check what was actually returned
file output.html
# Adjust your approach based on actual content
case $(file -b --mime-type output.html) in
"text/html")
# Parse as HTML
;;
"application/json")
# Parse as JSON
;;
"application/pdf")
# Handle as PDF
;;
*)
echo "Unexpected file type: $(file -b --mime-type output.html)"
;;
esac
Quick Reference Script
#!/bin/bash
# fetch-with-validation.sh
URL="$1"
OUTPUT="${2:-output.html}"
# Fetch with browser headers
curl -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" -o "$OUTPUT" "$URL"
# Get file info
SIZE=$(wc -c < "$OUTPUT")
TYPE=$(file -b --mime-type "$OUTPUT")
echo "Downloaded: $OUTPUT"
echo "Size: $SIZE bytes"
echo "Type: $TYPE"
# Warn about potential issues
if [ "$SIZE" -lt 1000 ]; then
echo "WARNING: File is very small - may be a placeholder response"
fi
if [ "$TYPE" = "text/html" ]; then
if grep -qi "javascript\|loading\|spinner" "$OUTPUT"; then
echo "WARNING: Content may be JavaScript-dependent"
fi
fi
Common Pitfalls
- Not checking file type: Assuming HTML when you got JSON or an error page
- Using default curl User-Agent: Many sites block or serve minimal content to bots
- Ignoring file size: Very small files are often error pages or placeholders
- Not following redirects: Some sites redirect based on User-Agent
よくある質問
ブラウザ風のヘッダーは何をしますか?
一般的なウェブブラウザからのリクエストに見せかけるため、一部のサイトが期待する形式になります。
プレースホルダーのページはどう見分けますか?
ファイルサイズが非常に小さいことや、loading、spinner、noscriptといった言葉があるかを確認します。
すべてのサイトで機能しますか?
いいえ。JavaScriptで内容を描画するページは、単純なダウンロードでは実行できないことがあるので、結果を確認するようガイドは述べています。
詳細
作者による元の説明
Handle websites requiring JavaScript by using curl with browser headers and validating file types.
repo: HKUDS/AgentPilot
人気
- GitHubのスター
- 7.8k
- ランキング
- #12892
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
agentpilot
7.8kエージェントが、作業を準備し、変更案を提案してテストし、評価するAgentPilotのループを実行することで、プロジェクトを段階的に改善できるよう支援します。
openspace
7.8kエージェントが、スキルを保存し取り出すツールであるOpenSpaceをセットアップし、MCPを通じてAIアプリに接続できるよう支援します。
rsi-arena
7.8kエージェントが、AIMEやTerminal-Benchなどの標準的なAIベンチマークテストをセットアップして実行し、異なる改善方法を比較できるよう支援します。
experiment-guide
7.8kエージェントが、プログラムを改善する方法を調べる間に、小さな実験を計画し、その結果を読み、発見を記録できるよう支援します。
似ているスキル
tavily
394kTavilyでウェブを検索し、特定のWebページから本文を取り出すようエージェントを支援します。深さ、ドメイン、日付のオプションも使えます。
blogwatcher
394kブログやRSS・Atomフィードを追跡し、新しい記事を確認して、読んだ記事に印を付けるようエージェントを支援します。
data-scraper-agent
280kエージェントが公開されているさまざまな情報源からデータを自動で収集できるよう支援します。スケジュール実行、情報の補強、結果の保存が可能です。オンラインデータの監視や追跡に役立ちます。