ai cooking
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 57 lines 1.5 kB view raw
1const { chromium } = require("playwright"); 2 3(async () => { 4 const browser = await chromium.launch({ headless: false }); 5 const context = await browser.newContext(); 6 const page = await context.newPage(); 7 8 page.on("request", req => { 9 const url = req.url(); 10 const rt = req.resourceType(); 11 12 const interesting = 13 url.includes("wholefoodsmarket.com") || 14 url.includes("wholefoods.com") || 15 url.includes("/_next/") || 16 rt === "xhr" || 17 rt === "fetch" || 18 req.isNavigationRequest(); 19 20 if (!interesting) return; 21 22 console.log("\n=== REQUEST ==="); 23 console.log("type:", rt); 24 console.log("method:", req.method()); 25 console.log("url:", url); 26 27 const body = req.postData(); 28 if (body) { 29 console.log("body:", body.slice(0, 2000)); 30 } 31 }); 32 33 page.on("response", async res => { 34 const url = res.url(); 35 const ct = res.headers()["content-type"] || ""; 36 37 const interesting = 38 url.includes("wholefoodsmarket.com") || 39 url.includes("wholefoods.com") || 40 url.includes("/_next/") || 41 ct.includes("json") || 42 ct.includes("html"); 43 44 if (!interesting) return; 45 46 console.log("\n=== RESPONSE ==="); 47 console.log("status:", res.status()); 48 console.log("url:", url); 49 console.log("content-type:", ct); 50 }); 51 52 await page.goto("https://www.wholefoodsmarket.com/grocery/search?k=syrah", { 53 waitUntil: "domcontentloaded" 54 }); 55 56 console.log("Interact manually now."); 57})();