मुखपृष्ठ / HTML और स्क्रीनशॉट: डाउनलोड प्रक्रिया

HTML और स्क्रीनशॉट: डाउनलोड प्रक्रिया

निगरानी में सहेजी गई HTML प्रतियाँ और स्क्रीनशॉट पाएँ। फ़ाइलों की उपलब्धता जाँचें और उन्हें डाउनलोड करने के चरण अपनाएँ।

इस पेज पर

ये तरीके बदलावों की निगरानी से संबंधित हैं। चुनी गई जाँच के समय सहेजा गया पेज HTML या PNG स्क्रीनशॉट डाउनलोड करें। ये रिपोर्ट के स्नैपशॉट हैं, वर्तमान पेज का डाउनलोड नहीं।

पहले include_state=true के साथ रिपोर्ट की पंक्तियाँ प्राप्त करें। पेज का url_md5 कॉपी करें और नीचे दिए गए state.files फ़ील्ड जाँचें। डाउनलोड में वही प्रोजेक्ट, रिपोर्ट और पेज उपयोग करें। स्क्रीनशॉट के लिए device=desktop या device=mobile चुनें; डिफ़ॉल्ट desktop है।

पैरामीटर विवरण
state.files.html_available HTML कॉपी की उपलब्धता
state.files.screenshot_desktop_available डेस्कटॉप स्क्रीनशॉट की उपलब्धता
state.files.screenshot_mobile_available मोबाइल स्क्रीनशॉट की उपलब्धता
state.files.*_expires_at / state.files.*_expires_in_days संबंधित फ़ाइल की समाप्ति तिथि और शेष दिन। संग्रह अवधि अज्ञात होने पर मान अनुपस्थित हो सकते हैं।

संग्रह अवधि चुनी गई जाँच से जुड़ी है। प्रोजेक्ट सेटिंग बदलने से पहले भुगतान की गई फ़ाइलों की अवधि नहीं बदलती। 404 file_not_available का अर्थ है फ़ाइल अनुपस्थित है, अवधि समाप्त है या आकार 10 MB से अधिक है। HTML text/html और स्क्रीनशॉट image/png के रूप में मिलते हैं।

  • HTML के लिए अनुमति: diff-htmlfiles:read।
  • स्क्रीनशॉट के लिए अनुमति: diff-screenshot:read।

GET /public-api/v1/diff-projects/{diff_project_id}/reports/{report_id}/pages/{url_md5}/html

चुनी गई रिपोर्ट के लिए दर्ज पृष्ठ का HTML डाउनलोड करता है।

GET /public-api/v1/diff-projects/{diff_project_id}/reports/{report_id}/pages/{url_md5}/screenshot

स्क्रीनशॉट डाउनलोड करता है। क्वेरी: device=desktop या device=mobile।

HTML डाउनलोड करें

curl

curl --fail-with-body --silent --show-error --location \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Accept: text/html' \
  --output 'page.html' \
  'https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/html'

JavaScript

const { writeFile } = require("node:fs/promises")

async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/html", {
    method: "GET",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "text/html",
    },
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  await writeFile("page.html", Buffer.from(await response.arrayBuffer()))
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})

Python

import json
from pathlib import Path
import requests

url = "https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/html"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Accept": "text/html",
}

response = requests.request(
    "GET",
    url,
    headers=headers,
    timeout=30,
)
response.raise_for_status()
Path("page.html").write_bytes(response.content)

PHP

<?php

$curl = curl_init('https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/html');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_API_KEY',
        'Accept: text/html',
    ],
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if (file_put_contents('page.html', $response) === false) {
    throw new RuntimeException('Unable to save response file');
}

Go

package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/html", nil)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	request.Header.Set("Accept", "text/html")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	output, err := os.Create("page.html")
	if err != nil {
		panic(err)
	}

	if _, err := io.Copy(output, response.Body); err != nil {
		output.Close()
		panic(err)
	}
	if err := output.Close(); err != nil {
		panic(err)
	}
}

Google Apps Script

function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/html", {
    method: "get",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "text/html",
    },
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  DriveApp.createFile(response.getBlob().setName("page.html"));
}

PNG डाउनलोड करें

curl

curl --fail-with-body --silent --show-error --location \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Accept: image/png' \
  --output 'screenshot.png' \
  'https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/screenshot?device=desktop'

JavaScript

const { writeFile } = require("node:fs/promises")

async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/screenshot?device=desktop", {
    method: "GET",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "image/png",
    },
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  await writeFile("screenshot.png", Buffer.from(await response.arrayBuffer()))
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})

Python

import json
from pathlib import Path
import requests

url = "https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/screenshot?device=desktop"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Accept": "image/png",
}

response = requests.request(
    "GET",
    url,
    headers=headers,
    timeout=30,
)
response.raise_for_status()
Path("screenshot.png").write_bytes(response.content)

PHP

<?php

$curl = curl_init('https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/screenshot?device=desktop');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_API_KEY',
        'Accept: image/png',
    ],
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if (file_put_contents('screenshot.png', $response) === false) {
    throw new RuntimeException('Unable to save response file');
}

Go

package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/screenshot?device=desktop", nil)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	request.Header.Set("Accept", "image/png")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	output, err := os.Create("screenshot.png")
	if err != nil {
		panic(err)
	}

	if _, err := io.Copy(output, response.Body); err != nil {
		output.Close()
		panic(err)
	}
	if err := output.Close(); err != nil {
		panic(err)
	}
}

Google Apps Script

function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/diff-projects/PROJECT_ID/reports/last/pages/URL_MD5/screenshot?device=desktop", {
    method: "get",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "image/png",
    },
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  DriveApp.createFile(response.getBlob().setName("screenshot.png"));
}