वेब कॅप्चर आणि रूपांतरित करण्यासाठी साधने

Node.js सह वेबसाइट्सवरून HTML सारण्या कॅप्चर करा

नोड.जेएस एपीआय

एचटीएमएल सारण्या रूपांतरित करण्याचे अनेक मार्ग आहेत into जेएसओएन, सीएसव्ही आणि एक्सेल स्प्रेडशीट वापरुन GrabzIt चे Node.js API, सविस्तर अशी काही सर्वात उपयुक्त तंत्रे आहेत. तथापि आपण सुरू करण्यापूर्वी लक्षात ठेवा की कॉल केल्यावर url_to_table, html_to_table or file_to_table पद्धती save or save_to टेबल कॅप्चर करण्यासाठी मेथड कॉल केला पाहिजे. ही सेवा आपल्यासाठी योग्य आहे की नाही हे आपण त्वरीत पाहू इच्छित असल्यास आपण प्रयत्न करू शकता एचटीएमएल टेबल्स कॅप्चर करण्याचा थेट डेमो URL वरून.

मूलभूत पर्याय

हा विशिष्ट पद्धत कॉल निर्दिष्ट केलेल्या URL च्या वेबपृष्ठामधील प्रथम HTML टेबल रूपांतरित करेल, into CSV दस्तऐवज. हा कोड स्निपेट निर्दिष्ट वेबपृष्ठामध्ये किंवा एचटीएमएल इनपुटमध्ये आढळलेल्या प्रथम एचटीएमएल टेबलमध्ये रूपांतरित करेल intसीएसव्ही दस्तऐवज

client.url_to_table("https://www.tesla.com");
//Then call the save or save_to method
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>");
//Then call the save or save_to method
client.file_to_table("tables.html");
//Then call the save or save_to method

डीफॉल्टनुसार हे त्यास ओळखत असलेल्या प्रथम सारणीचे रुपांतर करेल intओए टेबल. तथापि वेब पृष्ठामधील दुसरी सारणी एक्सएनयूएमएक्सला पास करून रूपांतरित केली जाऊ शकते tableNumberToInclude मालमत्ता.

var grabzit = require('grabzit');

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

var options = {"tableNumberToInclude":2};

client.url_to_table("https://www.tesla.com", options);
//Then call the save or save_to method
client.save_to("result.csv", 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 = {"tableNumberToInclude":2};

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>", options);
//Then call the save or save_to method
client.save_to("result.csv", 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 = {"tableNumberToInclude":2};

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

आपण निर्दिष्ट करू शकता targetElement निर्दिष्ट केलेल्या घटक आयडीमधील केवळ तक्त्यांचे रूपांतरण सुनिश्चित करेल अशी मालमत्ता.

var grabzit = require('grabzit');

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

var options = {"targetElement":"stocks_table"};

client.url_to_table("https://www.tesla.com", options);
//Then call the save or save_to method
client.save_to("result.csv", 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 = {"targetElement":"stocks_table"};

client.html_to_table("<html><body><table id='stocks_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>", options);
//Then call the save or save_to method
client.save_to("result.csv", 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 = {"targetElement":"stocks_table"};

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

वैकल्पिकरित्या आपण वेब पृष्ठावरील सर्व टेबल्स बरोबर नेऊन कॅप्चर करू शकता includeAllTables प्रॉपर्टी, तथापि हे केवळ JSON आणि XLSX स्वरूपनासह कार्य करेल. हा पर्याय व्युत्पन्न केलेल्या स्प्रेडशीट वर्कबुकमध्ये प्रत्येक टेबलला नवीन पत्रकात ठेवेल.

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","xlsx","includeHeaderNames":true,"includeAllTables":true};

client.url_to_table("https://www.tesla.com", options);
//Then call the save or save_to method
client.save_to("result.xlsx", 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","xlsx","includeHeaderNames":true,"includeAllTables":true};

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>", options);
//Then call the save or save_to method
client.save_to("result.xlsx", 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","xlsx","includeHeaderNames":true,"includeAllTables":true};

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

एचटीएमएल टेबल्सला जेएसओएन मध्ये रूपांतरित करा

नोड.जेज आणि ग्रॅबझिट वापरुन आपण HTML सारण्या रूपांतरित करू शकता intओ JSON, फक्त निर्दिष्ट करा json फॉरमॅट पॅरामीटर मध्ये एकदा खालील उदाहरणात दर्शविल्याप्रमाणे save_to मेथड पूर्ण झाल्यावर ऑन-अपूर्ण फंक्शनला JSON असे म्हणतात परिणामी व्हेरिएबलला नंतर इनबिल्ट नोड.जे द्वारे विश्लेषित केले जाते. JSON.parse एचटीएमएल टेबलचे प्रतिनिधित्व करणारे ऑब्जेक्ट तयार करण्यासाठी फंक्शन.

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","json","includeHeaderNames":true,"includeAllTables":true};
client.url_to_table("https://www.tesla.com", options);

client.save_to(null, function(error, result){
    if (result != null)
    {
        var tableObj = JSON.parse(result);
    }
});

सानुकूल अभिज्ञापक

आपण एक सानुकूल अभिज्ञापक पास करू शकता टेबल खाली दर्शविल्या गेलेल्या पद्धती, हे मूल्य नंतर आपल्या 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_table("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_table("<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_table("example.html", options);
//Then call the save method
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});