This Val allows you to analyze webpages and answer questions about them based on their HTML, CSS, and JavaScript content.
Simply visit the Val URL in your browser to use the web interface:
You can also use this Val programmatically by sending a POST request with JSON:
{ "url": "https://example.com", "question": "What is the main heading on this page?" }
curl -X POST https://api.val.town/v1/run/yourusername/webpage-analyzer \ -H "Content-Type: application/json" \ -d '{"url": "https://example.com", "question": "What is the main heading on this page?"}'
const response = await fetch('https://api.val.town/v1/run/yourusername/webpage-analyzer', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://example.com',
question: 'What is the main heading on this page?'
}),
});
const data = await response.json();
console.log(data.answer);
The API returns a JSON response with the following structure:
{ "url": "https://example.com", "question": "What is the main heading on this page?", "answer": "The main heading on the page is 'Example Domain'." }
This Val requires an OpenAI API key to be set as an environment variable in your Val Town account.