Created
May 25, 2024 02:47
-
-
Save yoeven/41cb1c258cdae46afe06e783cb6d6c56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const endPoint = "https://api.jigsawstack.com/v1/ai/scrape"; | |
const run = async (url: string, prompts: string[]) => { | |
const resp = await fetch(endPoint, { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json", | |
"x-api-key": "KEY", | |
}, | |
body: JSON.stringify({ | |
url, | |
element_prompts: prompts, | |
}), | |
}); | |
const result: any = await resp.json(); | |
if (resp.ok) { | |
const cleanedResult = result.data.map((d: any) => d.results.map((r: any) => r.text)).flat(); | |
console.log("result: ", JSON.stringify(cleanedResult, null, 2)); | |
} else { | |
console.error(result); | |
} | |
}; | |
const websiteToScrape = | |
"https://www.ebay.com.sg/itm/375439362507?itmmeta=01HYMMCJ6J1YFZEXJ6T3QPQ0SV&hash=item5769ee09cb:g:mEoAAOSwHmJmSsA~&itmprp=enc%3AAQAJAAAAwOPCOuWuRoFF%2FoWro2382LCwR51g1dWNwJexAdzgwhFrFlTAxJpTyCa1e4o8dIdnVeMuFAMqHMVQnFcYBuWFYjSHYgk4jHlnNX9Ulz1IbAM9hc5AcdrLCBx1ASC9ZmtrsIHjEhTvgwH0gW7Ru%2FEEABh09UCnvV0vP7G8RfBm%2BZS8Rgi8gvHO3lahusNuPoTfAHb9QXTJ05f672xE9q1Hx%2B%2FJnWLDjeSIzOUwiRi1EPWcZpW%2BjWMAYZ9mqGZ%2FUOaDig%3D%3D%7Ctkp%3ABk9SR6yjspT1Yw"; | |
run(websiteToScrape, ["prices"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment