વેબસાઇટના સ્ક્રીનશshotsટ્સ અને વધુ મૂકવાની શ્રેષ્ઠ રીત into તમારી નોડ.જેએસ એપ્લિકેશન આ પગલાંને અનુસરીને છે:
આ પુસ્તકાલય છે માત્ર સર્વર બાજુ. જો તમે ક્લાયંટ-સાઇડ જાવાસ્ક્રિપ્ટ સાથે કuresપ્ચર્સ પર પ્રક્રિયા કરવા માંગો છો, તો તમારે અમારું ઉપયોગ કરવો જોઈએ ક્લાયંટ બાજુ જાવાસ્ક્રિપ્ટ API તેના બદલે
API નો ઉપયોગ કરવા માટે તમારે પહેલા બનાવવાની જરૂર રહેશે ક્લાઈન્ટ objectબ્જેક્ટ, તમારા પસાર એપ્લિકેશન કી અને એપ્લિકેશન ગુપ્ત તમારા GrabzIt એકાઉન્ટથી કંસ્ટ્રક્ટર સુધી.
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
પછી એક વાપરો છબી, પીડીએફ, એનિમેશન or ટેબલ કેપ્ચર પદ્ધતિઓ URL ને or એચટીએમએલ કન્વર્ટ.
// To take a image screenshot client.url_to_image("https://www.tesla.com"); // Or to take a PDF screenshot client.url_to_pdf("https://www.tesla.com"); // Or to convert online videos into animated GIF's client.url_to_animation("http://www.example.com/video.avi"); // Or to capture table(s) client.url_to_table("https://www.tesla.com");
// To convert HTML into a image client.html_to_image("<html><body><h1>Hello World!</h1></body></html>"); // Or convert HTML into a PDF document client.html_to_pdf("<html><body><h1>Hello World!</h1></body></html>"); // Or convert HTML into a CSV, XLSX or JSON document client.html_to_table("<html><body><table><tr><th>Name</th><th>Age</th></tr> <tr><td>Tom</td><td>23</td></tr><tr><td>Nicola</td><td>26</td></tr> </table></body></html>");
// To convert HTML file into a image client.file_to_image("example.html"); // Or convert HTML file into a PDF document client.file_to_pdf("example.html"); // Or convert HTML file into a CSV, XLSX or JSON document client.file_to_table("tables.html");
આગળ કેપ્ચર હોવું આવશ્યક છે saveડી, આ કરવા માટે તમારે ક્યાં તો ઉપયોગ કરવો જ જોઇએ save
or save_to
પદ્ધતિ, જે બંને આવી છે તે કોઈપણ ભૂલોને હેન્ડલ કરવા માટે ફંક્શનમાં પસાર થાય છે. આ save નીચે મેથડ ક callલમાં URL નો સમાવેશ થાય છે હેન્ડલર કે પ્રક્રિયા કરશે કૉલબૅક GrabzIt થી અને save સ્ક્રીનશોટ અથવા કેપ્ચર.
client.save("http://www.example.com/handler", function (error, id){ if (error != null){ throw error; } });
બીજો વિકલ્પ એ વાપરવાનો છે સુસંગત save_to પદ્ધતિ, જે તમારી એપ્લિકેશનને સ્ક્રીનશોટ બનાવતી વખતે પ્રતીક્ષા કરવા દબાણ કરશે જેથી તે ફક્ત ઉપયોગમાં લેવાય save પદ્ધતિનો ઉપયોગ કરી શકાતો નથી.
એકવાર સ્ક્રીનશોટ બન્યા પછી તે આપમેળે થઈ જશે saveડી પૂરી પાડવામાં આવેલ ફાઇલ પાથ પર. નોંધ લો કે નોડ.જેએસ લાઇબ્રેરી ફક્ત સર્વર બાજુ પર જ કાર્ય કરશે કારણ કે તેને યોગ્ય રીતે કાર્ય કરવા માટે સર્વર સુવિધાઓની આવશ્યકતા છે.
client.save_to("images/result.jpg", function (error, id){ //this callback is called once the capture is downloaded if (error != null){ throw error; } });
સ્ક્રીનશોટ બનાવતી વખતે, એનિમેટેડ જી.એફ.એસ. અથવા કન્વર્ટ એચટીએમએલ સહિતના ઘણા બધા વિકલ્પો છે; બ્રાઉઝરની heightંચાઈ, બ્રાઉઝરની પહોળાઈ, સ્ક્રીનશોટની heightંચાઇ, સ્ક્રીનશshotટની પહોળાઈ, સ્ક્રીનશ takenટ લેવાય તે પહેલાંનો વિલંબ અને સ્ક્રીનશ ofટનું છબી બંધારણ. આ બધા વિકલ્પો અને વેબને કન્વર્ટ કરવાની ક્ષમતા માટે intઓ પીડીએફ, સીએસવી અથવા એનિમેટેડ જીઆઇએફના કૃપા કરીને આ જુઓ ક્લાઈન્ટ દસ્તાવેજીકરણ.