$API_TOKEN=<YOUR_API_TOKEN>
$cat > input.json << 'EOF'
<{
< "startUrls": [
< {
< "url": "https://www.amazon.com"
< }
< ],
< "actions": [
< {
< "type": "humanActivity"
< },
< {
< "type": "screenshot",
< "key": "amazon-home"
< },
< {
< "type": "type",
< "selector": "#twotabsearchtextbox",
< "value": "mechanical keyboard"
< },
< {
< "type": "click",
< "selector": "#nav-search-submit-button"
< },
< {
< "type": "wait",
< "time": 3000
< },
< {
< "type": "screenshot",
< "key": "amazon-search"
< },
< {
< "type": "humanActivity"
< },
< {
< "type": "scroll",
< "pages": 2
< },
< {
< "type": "screenshot",
< "fullPage": true,
< "key": "amazon-results"
< },
< {
< "type": "javascript",
< "expression": "(() => { const items = [...document.querySelectorAll('[data-component-type=\"s-search-result\"]')].slice(0, 5).map((el, i) => ({ rank: i+1, title: el.querySelector('h2')?.textContent?.trim(), price: el.querySelector('.a-price .a-offscreen')?.textContent, rating: el.querySelector('.a-icon-alt')?.textContent, url: el.querySelector('h2 a')?.href })); return JSON.stringify(items); })()"
< },
< {
< "type": "extractContent",
< "format": "text"
< }
< ]
<}
<EOF
$curl "https://api.apify.com/v2/acts/nocturne~stealth-website-crawler/runs?token=$API_TOKEN" \
< -X POST \
< -d @input.json \
< -H 'Content-Type: application/json'