Files
Clawd BotandClaude Opus 4.6 ca9b510922 chore: align with upstream openclaw/openclaw and overlay local additions
- Reset master to upstream/main (16,697 commits)
- Overlay 2,271 local-only files (skills, tools, workspace, configs, apps)
- Restore IDENTITY.md and USER.md templates
- Build verified, gateway running, Discord working

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-03-03 07:40:46 +01:00

43 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""
Scrapling CLI helper — til brug fra OpenClaw agenter.
Usage: python3 scrape.py <url> [css_selector]
"""
import sys
import json
def main():
if len(sys.argv) < 2:
print("Usage: python3 scrape.py <url> [css_selector]")
sys.exit(1)
url = sys.argv[1]
selector = sys.argv[2] if len(sys.argv) > 2 else None
try:
from scrapling import Fetcher
except ImportError:
print("Scrapling ikke installeret. Kør: pip install 'scrapling[ai]' --break-system-packages")
sys.exit(1)
page = Fetcher().get(url, stealthy_headers=True)
if selector:
elements = page.css(selector)
results = [e.get().extract() for e in elements]
print(json.dumps(results, ensure_ascii=False, indent=2))
else:
# Returner title + meta description + h1/h2 overskrifter
out = {
'url': url,
'status': page.status,
'title': (page.css('title').get() or '').extract() if page.css('title').get() else '',
'h1': [e.get().extract() for e in page.css('h1')],
'h2': [e.get().extract() for e in page.css('h2')][:5],
'links': [e.get().extract() for e in page.css('a')][:20],
}
print(json.dumps(out, ensure_ascii=False, indent=2))
if __name__ == '__main__':
main()