वेब पर कब्जा और परिवर्तित करने के लिए उपकरण

कैप्चर वेबसाइट स्क्रीनशॉट या HTML को इमेज में बदलें

Node.js एपीआई

निम्नलिखित सुविधाओं का उपयोग करके वेबसाइटों की सही छवि स्क्रीनशॉट बनाएं GrabzIt की Node.js एपीआई। हालांकि इससे पहले कि आप याद रखें कि कॉल करने के बाद url_to_image, html_to_image or file_to_image तरीके save or save_to स्क्रीनशॉट लेने के लिए विधि को बुलाया जाना चाहिए।

मूल विकल्प

वेब पेज का स्क्रीनशॉट लेने के लिए या बस एक पैरामीटर की आवश्यकता होती है HTML कन्वर्ट intओए छवि जैसा कि निम्नलिखित उदाहरण में दिखाया गया है।

client.url_to_image("https://www.tesla.com");
//Then call the save or save_to method
client.html_to_image("<html><body><h1>Hello World!</h1></body></html>");
//Then call the save or save_to method
client.file_to_image("example.html");
//Then call the save or save_to method

छवि स्क्रीनशॉट प्रारूप

GrabzIt के Node.js एपीआई JPG, PNG, WEBP, BMP (8 बिट, 16 बिट, 24 बिट या 32 बिट) और TIFF सहित कई स्वरूपों में छवि स्क्रीनशॉट ले सकते हैं। छवि स्क्रीनशॉट के लिए डिफ़ॉल्ट प्रारूप JPG है। हालाँकि, JPG छवि की गुणवत्ता इन परिस्थितियों में कुछ अनुप्रयोगों के लिए पर्याप्त अच्छी नहीं हो सकती है क्योंकि छवि स्क्रीनशॉट के लिए PNG प्रारूप की सिफारिश की जाती है क्योंकि यह गुणवत्ता और फ़ाइल आकार के बीच एक अच्छा संतुलन देता है। नीचे दिए गए उदाहरण में PNG प्रारूप का उपयोग करके एक छवि स्क्रीनशॉट दिखाया गया है।

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"format":"png"};

client.url_to_image("https://www.tesla.com", options);
//Then call the save or save_to method
client.save_to("result.png", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"format":"png"};

client.html_to_image("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the save or save_to method
client.save_to("result.png", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"format":"png"};

client.file_to_image("example.html", options);
//Then call the save or save_to method
client.save_to("result.png", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});

ब्राउज़र का आकार

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

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"browserWidth":1366, "browserHeight":768};

client.url_to_image("https://www.tesla.com", options);
//Then call the save or save_to method
client.save_to("result.jpg", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"browserWidth":1366, "browserHeight":768};

client.html_to_image("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the save or save_to method
client.save_to("result.jpg", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"browserWidth":1366, "browserHeight":768};

client.file_to_image("example.html", options);
//Then call the save or save_to method
client.save_to("result.jpg", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});

छवि का आकार बदलें

एक छवि का आकार बदलना आसान है, छवि को विकृत किए बिना करना थोड़ा कठिन है। पूरी प्रक्रिया को सरल बनाने के लिए हम आपको इसका उपयोग करने की सलाह देते हैं सरल छवि आयाम कैलकुलेटर.

यदि आप ब्राउज़र की चौड़ाई और ऊँचाई की तुलना में छवि की चौड़ाई और ऊँचाई को बड़े आकार में बढ़ाना चाहते हैं, जो डिफ़ॉल्ट रूप से 1366 पिक्सेल द्वारा 728 है, तो ब्राउज़र की चौड़ाई और ऊँचाई को भी मिलान के लिए बढ़ाना होगा।

कस्टम पहचानकर्ता

आप एक कस्टम पहचानकर्ता को पास कर सकते हैं की छवि नीचे दिखाए गए तरीके, यह मान तब आपके GrabzIt Node.js हैंडलर को वापस कर दिया जाता है। उदाहरण के लिए, यह कस्टम पहचानकर्ता एक डेटाबेस पहचानकर्ता हो सकता है, जो स्क्रीनशॉट को किसी विशेष डेटाबेस रिकॉर्ड से जुड़ा होने की अनुमति देता है।

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"customId":123456};

client.url_to_image("https://www.tesla.com", options);
//Then call the save method
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"customId":123456};

client.html_to_image("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the save method
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"customId":123456};

client.file_to_image("example.html", options);
//Then call the save method
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});

पूर्ण लंबाई स्क्रीनशॉट

GrabzIt आपको एक संपूर्ण वेब पेज की पूरी लंबाई का स्क्रीनशॉट लेने की अनुमति देता है ऐसा करने के लिए आपको एक -1 पास करना होगा browserHeight संपत्ति। यह सुनिश्चित करने के लिए कि छवि ब्राउज़र के आकार से मेल खाती है, यह एक -1 पास है height और width गुण।

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"browserHeight":-1,"width":-1, "height":-1};

client.url_to_image("https://www.tesla.com", options);
//Then call the save or save_to method
client.save_to("result.jpg", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"browserHeight":-1,"width":-1, "height":-1};

client.html_to_image("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the save or save_to method
client.save_to("result.jpg", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"browserHeight":-1,"width":-1, "height":-1};

client.file_to_image("example.html", options);
//Then call the save or save_to method
client.save_to("result.jpg", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});

आप उन थंबनेल को भी वापस कर सकते हैं जो क्रॉप नहीं हैं, लेकिन सावधान रहें इससे बड़ी छवियां बन सकती हैं। ऐसा करने के लिए -1 को पास करें height और / या width गुण। एक -1 पास होने वाले आयाम को क्रॉप नहीं किया जाएगा।

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"width":-1, "height":-1};

client.url_to_image("https://www.tesla.com", options);
//Then call the save or save_to method
client.save_to("result.jpg", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"width":-1, "height":-1};

client.html_to_image("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the save or save_to method
client.save_to("result.jpg", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"width":-1, "height":-1};

client.file_to_image("example.html", options);
//Then call the save or save_to method
client.save_to("result.jpg", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
ध्यान दें कि कोई पूर्ण लंबाई ब्राउज़र चौड़ाई नहीं है!

इन विशेष मानों का उपयोग करने का मतलब है कि आप एक स्क्रीनशॉट बना सकते हैं जो यदि आप चाहें तो पूरे वेब पेज का एक पूर्ण पैमाने पर संस्करण है!

किसी पृष्ठ तत्व का स्क्रीनशॉट लें

GrabzIt आपको एक HTML तत्व का स्क्रीनशॉट लेने की अनुमति देता है, जैसे कि ए div or span टैग करें, और उसकी सभी सामग्री को कैप्चर करें। ऐसा करने के लिए कि आप जिस HTML एलिमेंट को स्क्रीनशॉट लेना चाहते हैं, उसे एक के रूप में निर्दिष्ट किया जाना चाहिए सीएसएस चयनकर्ता.

...
<div id="features">
	<img src="http://www.example.com/boat.jpg"/><h3>New Boat Launched</h3>
</div>
...

नीचे दिए गए उदाहरण के लिए हम आईडी "फीचर्स" के साथ div का चयन करेंगे और इसे 250 x 250px JPM इमेज के रूप में आउटपुट करेंगे।

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

// The 250 parameters indicates that image should be sized to 250 x 250 px
var options = {"width":250, "height":250, "format":"jpg","target":"#features"};

client.url_to_image("http://www.bbc.co.uk/news", options);
//Then call the save or save_to method
client.save_to("result.jpg", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});

अगला उदाहरण "फीचर्स" div का एक और स्क्रीनशॉट लेता है लेकिन इस बार JPEG इमेज को आउटपुट करता है जो div का सटीक आकार है।

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

// The minus ones indicates that image should not be cropped
var options = {"browserHeight":-1, "width":-1, "height":-1, "format":"jpg", "target":"#features"};

client.url_to_image("http://www.bbc.co.uk/news", options);
//Then call the save or save_to method
client.save_to("result.jpg", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});