spagindex.html30 matches
17<br />
1819Replace <code>name</code> with the name you gave the image. Names can
20contain spaces, emojis, anything!
21</p>
100<audio controls style="display: none" id="preview-audio"></audio>
101</div>
102<input type="file" id="file" accept="audio/*, image/*" required />
103</label>
104<label for="singing">
139const nameInput = document.getElementById("name");
140const fileInput = document.getElementById("file");
141const previewImage = document.getElementById("preview");
142const previewAudio = document.getElementById("preview-audio");
143const uploadButton = document.getElementById("upload-button");
154reader.onload = () => {
155const dataUrl = reader.result;
156previewImage.src = dataUrl; // the form just grabs whatever is here and uploads this, which may even be audio
157previewAudio.src = dataUrl;
158};
167});
168169previewImage.addEventListener("load", () => {
170previewImage.style.display = "block";
171});
172175});
176177previewImage.addEventListener("error", () => {
178previewImage.style.display = "none";
179});
180227event.preventDefault();
228const name = encodeURIComponent(nameInput.value);
229const dataUrl = previewImage.src;
230const body = JSON.stringify({ name, dataUrl });
231uploadButton.disabled = true;
239nameInput.value = "";
240fileInput.value = "";
241previewImage.src = "";
242previewAudio.src = "";
243} else {
321322const contentType = response.headers.get("content-type");
323if (contentType.startsWith("image")) {
324const imageElement = document.createElement("img");
325imageElement.loading = "lazy";
326imageElement.style.width = "100%";
327imageElement.style.objectFit = "contain";
328imageElement.style.height = "300px";
329// src the response
330const blob = await response.blob();
331imageElement.src = URL.createObjectURL(blob);
332imageElement.onerror = () => {
333imageElement.remove();
334};
335previewContainer.appendChild(imageElement);
336} else if (contentType.startsWith("audio")) {
337const audioElement = document.createElement("audio");
369});
370371// const imageElement = document.createElement("img");
372// imageElement.loading = "lazy";
373// imageElement.src = `https://tode.party?${upload.name}`;
374// imageElement.style.width = "100%";
375// imageElement.style.objectFit = "contain";
376// imageElement.style.border = "1px solid rgb(159, 174, 238)";
377// imageElement.style.backgroundColor = "rgb(55, 67, 98)";
378// imageElement.style.height = "300px";
379// imageElement.onerror = () => {
380// imageElement.remove();
381// };
382
spagindex.html30 matches
17<br />
1819Replace <code>name</code> with the name you gave the image. Names can
20contain spaces, emojis, anything!
21</p>
100<audio controls style="display: none" id="preview-audio"></audio>
101</div>
102<input type="file" id="file" accept="audio/*, image/*" required />
103</label>
104<label for="singing">
139const nameInput = document.getElementById("name");
140const fileInput = document.getElementById("file");
141const previewImage = document.getElementById("preview");
142const previewAudio = document.getElementById("preview-audio");
143const uploadButton = document.getElementById("upload-button");
154reader.onload = () => {
155const dataUrl = reader.result;
156previewImage.src = dataUrl; // the form just grabs whatever is here and uploads this, which may even be audio
157previewAudio.src = dataUrl;
158};
167});
168169previewImage.addEventListener("load", () => {
170previewImage.style.display = "block";
171});
172175});
176177previewImage.addEventListener("error", () => {
178previewImage.style.display = "none";
179});
180227event.preventDefault();
228const name = encodeURIComponent(nameInput.value);
229const dataUrl = previewImage.src;
230const body = JSON.stringify({ name, dataUrl });
231uploadButton.disabled = true;
239nameInput.value = "";
240fileInput.value = "";
241previewImage.src = "";
242previewAudio.src = "";
243} else {
321322const contentType = response.headers.get("content-type");
323if (contentType.startsWith("image")) {
324const imageElement = document.createElement("img");
325imageElement.loading = "lazy";
326imageElement.style.width = "100%";
327imageElement.style.objectFit = "contain";
328imageElement.style.height = "300px";
329// src the response
330const blob = await response.blob();
331imageElement.src = URL.createObjectURL(blob);
332imageElement.onerror = () => {
333imageElement.remove();
334};
335previewContainer.appendChild(imageElement);
336} else if (contentType.startsWith("audio")) {
337const audioElement = document.createElement("audio");
369});
370371// const imageElement = document.createElement("img");
372// imageElement.loading = "lazy";
373// imageElement.src = `https://tode.party?${upload.name}`;
374// imageElement.style.width = "100%";
375// imageElement.style.objectFit = "contain";
376// imageElement.style.border = "1px solid rgb(159, 174, 238)";
377// imageElement.style.backgroundColor = "rgb(55, 67, 98)";
378// imageElement.style.height = "300px";
379// imageElement.onerror = () => {
380// imageElement.remove();
381// };
382
utilsproject.test.ts1 match
169{
170headers: {
171"content-type": "image/svg+xml;charset=UTF-8",
172},
173},
140{
141headers: {
142"content-type": "image/svg+xml;charset=UTF-8",
143},
144},
instagramScrapingutils.ts2 matches
3132export interface InstagramPostMeta {
33imageUrl: string;
34caption: string;
35username: string;
5556return {
57imageUrl: await fetch(`https://www.instagram.com/p/${id}/media/?size=l`, {
58headers: {
59"Accept":
instagramScrapingindex.tsx34 matches
3233try {
34const { caption, username, imageUrl } = await instagramPostExtract(
35fullInstagramUrl,
36);
3738// If the 'proxyImage' parameter is present, proxy the image
39if (c.req.query("proxyImage") === "true") {
40try {
41const imageResponse = await fetch(imageUrl);
42if (!imageResponse.ok) {
43throw new Error(`Failed to fetch image: ${imageResponse.status}`);
44}
4546// Return the proxied image with appropriate content type
47const contentType = imageResponse.headers.get("Content-Type") ||
48"image/jpeg";
49return new Response(imageResponse.body, {
50headers: { "Content-Type": contentType },
51});
53if (fetchError instanceof Error) {
54return c.json({
55error: "Failed to proxy image: " + fetchError.message,
56}, 502);
57}
58}
59} else {
60// By default, return JSON with caption, username, and image URL
61// Construct a proper proxied image URL
62const url = new URL(c.req.url);
63const host = url.host;
64const protocol = url.protocol;
65const proxiedImageUrl = `${protocol}//${host}/extract?url=${
66encodeURIComponent(fullInstagramUrl)
67}&proxyImage=true`;
6869return c.json({
70caption,
71username,
72imageUrl: imageUrl,
73proxiedImageUrl: proxiedImageUrl,
74});
75}
99100try {
101const { caption, username, imageUrl } = await instagramPostExtract(
102fullInstagramUrl!,
103);
104105// If the 'proxyImage' parameter is present, proxy the image
106if (c.req.query("proxyImage") === "true") {
107try {
108const imageResponse = await fetch(imageUrl);
109if (!imageResponse.ok) {
110throw new Error(`Failed to fetch image: ${imageResponse.status}`);
111}
112113// Return the proxied image with appropriate content type
114const contentType = imageResponse.headers.get("Content-Type") ||
115"image/jpeg";
116return new Response(imageResponse.body, {
117headers: { "Content-Type": contentType },
118});
120if (fetchError instanceof Error) {
121return c.json({
122error: "Failed to proxy image: " + fetchError.message,
123}, 502);
124}
125}
126} else {
127// By default, return JSON with caption, username, and image URL
128// Construct a proper proxied image URL
129const url = new URL(c.req.url);
130const host = url.host;
131const protocol = url.protocol;
132const proxiedImageUrl = `${protocol}//${host}/extract/${
133encodeURIComponent(fullInstagramUrl!)
134}?proxyImage=true`;
135136return c.json({
137caption,
138username,
139imageUrl: imageUrl,
140proxiedImageUrl: proxiedImageUrl,
141});
142}
instagramScrapingREADME.md4 matches
1# Instagram Post Scraper
23A simple web application for extracting image and caption data from Instagram posts.
45## Endpoints
7- `/` - Main application page
8- `/extract?url={instagram_url}` - API endpoint to extract post data
9- `/extract?url={instagram_url}&proxyImage=true` - Endpoint to proxy Instagram images
1011## Usage
12131. Enter an Instagram post URL in the input field
142. The application will fetch the image and caption
153. Copy the text with attribution using the "Copy Text" button
164. Save the image (on mobile tap and hold)
17
instagramScrapingApp.tsx11 matches
5const [url, setUrl] = useState("");
6const [resultCaption, setResultText] = useState("");
7const [resultImage, setResultImage] = useState("");
8const [copyStatus, setCopyStatus] = useState("");
9const imageRef = useRef(null);
10const textRef = useRef(null);
1117console.log(data);
18setResultText(`Reposted from @${data.username}\n\n${data.caption}`);
19setResultImage(data.proxiedImageUrl);
20})
21.catch((error) => {
22console.error("Error fetching data:", error);
23setResultText("Error fetching data");
24setResultImage("");
25});
26}
44<div style={{ maxWidth: "600px", margin: "0 auto", padding: "20px" }}>
45<h1>Instagram Extracter</h1>
46<h2>Extract images from single-image instagram posts</h2>
4748<div>
49<label>
50{(resultImage && resultCaption)
51? "Post URL"
52: "Enter the URL to the Post"}
59/>
6061{!(resultImage && resultCaption) && (
62<p style={{ marginBottom: "10px" }}>
63Click the share button at the bottom left of post (the paper
67</div>
6869{resultImage && resultCaption && (
70<>
71{copyStatus && (
97<div style={{ marginTop: "20px" }}>
98<img
99ref={imageRef}
100src={resultImage}
101alt="Result"
102style={{ maxWidth: "100%", border: "1px solid #ccc" }}
103/>
104Click and hold, then click save image.
105</div>
106</div>
bingImageOfDayindex.tsx29 matches
2import { Hono } from "https://deno.land/x/hono/mod.ts";
3import { blob } from "https://esm.town/v/std/blob";
4import { backupBingImage } from "./backupImage.tsx";
5import { fetchBingImage } from "./fetchBingImage.tsx";
67const app = new Hono();
10app.get("/list", async (c) => {
11try {
12const images = await blob.list("bing-images-of-day/");
13const imageDates = images
14.map(img => img.key.replace("bing-images-of-day/", ""))
15.sort((a, b) => {
16const parseDate = (dateString: string) => {
20return parseDate(b).getTime() - parseDate(a).getTime();
21})
22.map(imageFile => [imageFile.replace(".jpg", ""), `${DEPLOY_URL}/get/${imageFile}`]);
2324return c.json(Object.fromEntries(imageDates));
25} catch (error) {
26return c.json([], 200);
30app.get("/get/:date", async (c) => {
31const date = c.req.param("date");
32const imageKey = `bing-images-of-day/${date}`;
3334try {
35const imageBlob = await blob.get(imageKey);
36if (!imageBlob) return c.json({ error: "Image not found" }, 404);
3738const modifiedResponse = new Response(imageBlob.body, {
39headers: {
40"Content-Type": "image/jpeg",
41"Access-Control-Allow-Origin": "*",
42},
45return modifiedResponse;
46} catch (error) {
47return c.json({ error: "Image not found" }, 404);
48}
49});
51app.get("/", async (c) => {
52try {
53// Use our helper function to fetch the current Bing image
54const response = await fetchBingImage();
55if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
5657const imageBlob = await response.blob();
5859return new Response(imageBlob, {
60headers: {
61"Content-Type": "image/jpeg",
62"Access-Control-Allow-Origin": "*",
63},
64});
65} catch (error) {
66return c.json({ error: "Failed to fetch current Bing image" }, 500);
67}
68});
70app.get("/backup", async (c) => {
71try {
72// Use our backup helper to save today's image
73await backupBingImage();
74return c.json({ success: true, message: "Image backed up successfully" });
75} catch (error) {
76return c.json({ error: "Failed to backup image" }, 500);
77}
78});
84path: "/",
85method: "GET",
86description: "Fetches the current Bing Image of the Day.",
87response: "JPEG image with headers `Content-Type: image/jpeg`.",
88},
89{
90path: "/list",
91method: "GET",
92description: "Lists all saved Bing Images of the Day.",
93response: "JSON object with dates as keys and URLs as values.",
94},
96path: "/get/:date",
97method: "GET",
98description: "Fetches a saved Bing Image of the Day for a specific date.",
99urlParams: "date - format: MM-DD-YYYY",
100response: "JPEG image or JSON error if not found.",
101},
102{
103path: "/backup",
104method: "GET",
105description: "Manually triggers a backup of today's Bing Image of the Day.",
106response: "JSON status message",
107},
bingImageOfDayREADME.md18 matches
1# Bing Image of the Day Archive
23This Val Town project fetches, displays, and archives the Bing Image of the Day, providing an API to access both current and historical images.
45## Overview
67- Fetch the current Bing Image of the Day
8- Archive images to Val Town blob storage with date-based naming
9- List all archived images with their dates
10- Retrieve specific historical images by date
1112## API Endpoints
14| Endpoint | Method | Description |
15|----------|--------|-------------|
16| `/` | GET | Returns the current Bing Image of the Day |
17| `/list` | GET | Returns a JSON object listing all archived images with dates as keys and URLs as values |
18| `/get/:date` | GET | Returns a specific archived image by date (format: MM-DD-YYYY) |
19| `/backup` | GET | Manually triggers a backup of the current Bing Image of the Day |
20| `/docs` | GET | Returns API documentation in JSON format |
2122### How It Works
2324- The service scrapes the Bing image from a public source (bing.gifposter.com)
25- Images are stored in Val Town's blob storage with keys in the format `bing-images-of-day/MM-DD-YYYY.jpg`
26- The main API serves both current and archived images with proper caching headers
27- Automation can be set up to trigger the backup endpoint daily to build a complete archive
2829## Usage Examples
3031### View Current Image
3233```
35```
3637Returns the current Bing Image of the Day as a JPEG with appropriate headers.
3839### List All Archived Images
4041```
53```
5455### Get Specific Image by Date
5657```
59```
6061Returns the image for January 15, 2024 as a JPEG.