feat: add images to all 50 recipes with frontmatter (Task 2)
Downloaded recipe images from source URLs (NYT Cooking, Love & Lemons, Food Network, etc.) via og:image scraping and DuckDuckGo search + page scraping for recipes without direct source URLs.
This commit is contained in:
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
slug="$1"
|
||||
url="$2"
|
||||
|
||||
echo "[$slug] Fetching $url" >&2
|
||||
html=$(curl -sL --max-time 15 "$url" 2>/dev/null) || { echo "[$slug] FETCH FAILED" >&2; echo ""; exit 0; }
|
||||
|
||||
# Try multiple og:image patterns
|
||||
img_url=$(echo "$html" | grep -oP 'property="og:image"\s+content="[^"]*"' | sed 's/.*content="//;s/"//' | head -1)
|
||||
|
||||
if [ -z "$img_url" ]; then
|
||||
img_url=$(echo "$html" | grep -oP 'name="og:image"\s+content="[^"]*"' | sed 's/.*content="//;s/"//' | head -1)
|
||||
fi
|
||||
|
||||
if [ -z "$img_url" ]; then
|
||||
img_url=$(echo "$html" | grep -oP 'content="[^"]*"[^>]*property="og:image"' | sed 's/.*content="//;s/".*//' | head -1)
|
||||
fi
|
||||
|
||||
if [ -n "$img_url" ]; then
|
||||
echo "[$slug] Found: $img_url" >&2
|
||||
echo "$img_url"
|
||||
else
|
||||
echo "[$slug] No og:image found" >&2
|
||||
fi
|
||||
Reference in New Issue
Block a user