Ana Sayfa / HTML ve ekran görüntüleri: işlem sırası

HTML ve ekran görüntüleri: işlem sırası

İzlemenin kaydettiği HTML kopyalarını ve ekran görüntülerini alın. Dosyaların kullanılabilirliğini kontrol edip indirme adımlarını izleyin.

Bu sayfada

Bu yöntemler değişiklik izlemeye aittir. Seçilen kontrol sırasında kaydedilen sayfa HTML dosyasını veya PNG ekran görüntüsünü indirir. Bunlar güncel sayfa değil, rapora ait kayıtlardır.

Önce include_state=true ile rapor satırlarını alın. Sayfanın url_md5 değerini kopyalayın ve aşağıdaki state.files alanlarını kontrol edin. İndirmede aynı proje, rapor ve sayfayı kullanın. Ekran görüntüsü için device=desktop veya device=mobile seçin; varsayılan desktop değeridir.

Parametre Açıklama
state.files.html_available HTML kopyasının kullanılabilirliği
state.files.screenshot_desktop_available Masaüstü ekran görüntüsünün kullanılabilirliği
state.files.screenshot_mobile_available Mobil ekran görüntüsünün kullanılabilirliği
state.files.*_expires_at / state.files.*_expires_in_days Dosyanın son saklama tarihi ve kalan gün sayısı. Saklama süresi bilinmiyorsa değerler bulunmayabilir.

Saklama süresi seçilen kontrole aittir. Proje ayarlarının değiştirilmesi, ücreti ödenmiş dosyaların süresini değiştirmez. 404 file_not_available, dosyanın bulunmadığını, süresinin dolduğunu veya 10 MB sınırını aştığını belirtir. HTML text/html, ekran görüntüleri image/png olarak döner.

  • HTML yetkisi: diff-htmlfiles:read.
  • Ekran görüntüsü yetkisi: diff-screenshot:read.

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

Seçilen rapor için kaydedilen sayfa HTML'sini indirir.

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

Ekran görüntüsünü indirir. Sorgu: device=desktop veya device=mobile.

HTML indir

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 indir

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"));
}