การสาธิตนี้แสดงวิธีการเรียก API เครื่องสกรีนช็อตออนไลน์โดยใช้ภาษาการเขียนโปรแกรม Visual Basic
ขั้นแรก คุณต้องสร้างบัญชีฟรี/พรีเมียมที่เว็บไซต์ www.screenshotmachine.com หลังจากลงทะเบียน คุณจะเห็นรหัสลูกค้าของคุณในโปรไฟล์ผู้ใช้ของคุณ วลีลับยังคงอยู่ที่นี่ โปรดใช้วลีลับเสมอเมื่อมีการเรียก API ของคุณจากเว็บไซต์สาธารณะ
ตั้งค่ารหัสลูกค้าและวลีลับ (หากจำเป็น) ในสคริปต์:
Dim customerKey As String = "PUT_YOUR_CUSTOMER_KEY_HERE"
Dim secretPhrase As String = "" REM leave secret phrase empty, If Not needed
ตั้งค่าตัวเลือกเพิ่มเติมเพื่อตอบสนองความต้องการของคุณ:
Dim options As New Dictionary( Of String , String )
REM mandatory parameter
options.Add( "url" , "https://www.google.com" )
REM all next parameters are optional, see our website screenshot API guide for more details
options.Add( "dimension" , "1366x768" ) REM Or "1366xfull" For full length screenshot
options.Add( "device" , "desktop" )
options.Add( "format" , "png" )
options.Add( "cacheLimit" , "0" )
options.Add( "delay" , "200" )
options.Add( "zoom" , "100" )
ข้อมูลเพิ่มเติมเกี่ยวกับตัวเลือกต่างๆ สามารถพบได้ใน API ภาพหน้าจอเว็บไซต์ของเรา
Imports System.Net
Public Class Client
Public Shared Sub Main(args() As String )
Dim customerKey As String = "PUT_YOUR_CUSTOMER_KEY_HERE"
Dim secretPhrase As String = "" REM leave secret phrase empty, If Not needed
Dim options As New Dictionary( Of String , String )
REM mandatory parameter
options.Add( "url" , "https://www.google.com" )
REM all next parameters are optional, see our website screenshot API guide for more details
options.Add( "dimension" , "1366x768" ) REM or "1366xfull" for full length screenshot
options.Add( "device" , "desktop" )
options.Add( "format" , "png" )
options.Add( "cacheLimit" , "0" )
options.Add( "delay" , "200" )
options.Add( "zoom" , "100" )
Dim sm As ScreenshotMachine = New ScreenshotMachine(customerKey, secretPhrase)
Dim apiUrl As String = sm.GenerateScreenshotApiUrl(options)
REM use final apiUrl where needed
Console.WriteLine(apiUrl)
End Sub
End Class
ลิงก์ apiUrl
ที่สร้างขึ้นสามารถวางในแท็ก <img>
หรือใช้ในตรรกะทางธุรกิจของคุณในภายหลังได้
หากคุณต้องการจัดเก็บภาพหน้าจอที่บันทึกไว้เป็นรูปภาพ เพียงโทร:
Dim apiUrl As String = sm.GenerateScreenshotApiUrl(options)
REM or save screenshot directly
Dim client As New WebClient()
Dim output As String = "output.png"
client.DownloadFile(apiUrl, output)
Console.WriteLine( "Screenshot saved as " + output)
ภาพหน้าจอที่ถ่ายจะถูกบันทึกเป็นไฟล์ output.png
ในไดเร็กทอรีปัจจุบัน
ตั้งค่าตัวเลือก PDF:
Dim options As New Dictionary( Of String , String )
REM mandatory parameter
options.Add( "url" , "https://www.google.com" )
REM all next parameters are optional, see our website to PDF API guide for more details
options.Add( "paper" , "letter" )
options.Add( "orientation" , "portrait" )
options.Add( "media" , "print" )
options.Add( "bg" , "nobg" )
options.Add( "delay" , "2000" )
options.Add( "scale" , "50" )
ข้อมูลเพิ่มเติมเกี่ยวกับตัวเลือกต่างๆ สามารถพบได้ในเว็บไซต์ของเราเป็น PDF API
Imports System.Net
Public Class ClientPdf
Public Shared Sub Main(args() As String )
Dim customerKey As String = "PUT_YOUR_CUSTOMER_KEY_HERE"
Dim secretPhrase As String = "" REM leave secret phrase empty, If Not needed
Dim options As New Dictionary( Of String , String )
REM mandatory parameter
options.Add( "url" , "https://www.google.com" )
REM all next parameters are optional, see our website to PDF API guide for more details
options.Add( "paper" , "letter" )
options.Add( "orientation" , "portrait" )
options.Add( "media" , "print" )
options.Add( "bg" , "nobg" )
options.Add( "delay" , "2000" )
options.Add( "scale" , "50" )
Dim sm As ScreenshotMachine = New ScreenshotMachine(customerKey, secretPhrase)
Dim pdfApiUrl As String = sm.GeneratePdfApiUrl(options)
REM save PDF file
Dim client As New WebClient()
Dim output As String = "output.pdf"
client.DownloadFile(pdfApiUrl, output)
Console.WriteLine( "PDF saved as " + output)
End Sub
End Class
PDF ที่บันทึกจะถูกบันทึกเป็นไฟล์ output.pdf
ในไดเร็กทอรีปัจจุบัน
ใบอนุญาต MIT (MIT)