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

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

जावा एपीआय

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

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

हा कोड स्निपेट निर्दिष्ट केलेल्या वेबपृष्ठामध्ये आढळणारी प्रथम HTML सारणी रूपांतरित करेल intसीएसव्ही दस्तऐवज

grabzIt.URLToTable("https://www.tesla.com");
//Then call the Save or SaveTo method
grabzIt.HTMLToTable("<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 SaveTo method
grabzIt.FileToTable("tables.html");
//Then call the Save or SaveTo method

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

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setTableNumberToInclude(2);

grabzIt.URLToTable("https://www.tesla.com", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setTableNumberToInclude(2);

grabzIt.HTMLToTable("<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 SaveTo method
grabzIt.SaveTo("result.csv");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setTableNumberToInclude(2);

grabzIt.FileToTable("tables.html", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv");

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

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setTargetElement("stocks_table");

grabzIt.URLToTable("https://www.tesla.com", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setTargetElement("stocks_table");

grabzIt.HTMLToTable("<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 SaveTo method
grabzIt.SaveTo("result.csv");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setTargetElement("stocks_table");

grabzIt.FileToTable("tables.html", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv");

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

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setFormat(TableFormat.XLSX);
options.setIncludeAllTables(true);

grabzIt.URLToTable("https://www.tesla.com", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.xlsx");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setFormat(TableFormat.XLSX);
options.setIncludeAllTables(true);

grabzIt.HTMLToTable("<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 SaveTo method
grabzIt.SaveTo("result.xlsx");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setFormat(TableFormat.XLSX);
options.setIncludeAllTables(true);

grabzIt.FileToTable("tables.html", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.xlsx");

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

ग्रॅबझीट वेबवर आढळलेल्या एचटीएमएल तक्त्यांना जेएसओएन मध्ये रूपांतरित करू शकते, त्याऐवजी फक्त जेएसओएन स्वरूप निर्दिष्ट करा. खाली दिलेल्या उदाहरणात डेटा समक्रमितपणे वाचला जातो आणि ए म्हणून परत केला जातो GrabzItFile वापरून ऑब्जेक्ट SaveTo पध्दत, तथापि आपण सामान्यपणे अशी शिफारस केली जाते एसिंक्रोनोली.

रूपांतरण पूर्ण झाल्यावर toString एक म्हणून JSON मिळविण्यासाठी पद्धत म्हटले जाते string, यासारख्या लायब्ररीद्वारे विश्लेषित केले जाऊ शकते गूगल जीसन.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setFormat(TableFormat.JSON);
options.setTableNumberToInclude(1);

grabzIt.URLToTable("https://www.tesla.com", options);

GrabzItFile file = grabzIt.SaveTo();
if (file != null)
{
    String json = file.toString();
}

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

आपण एक सानुकूल अभिज्ञापक पास करू शकता टेबल खाली दर्शविल्या गेलेल्या पद्धती, हे मूल्य नंतर आपल्या GrabzIt जावा हँडलरला परत केले जाईल. उदाहरणार्थ हा सानुकूल अभिज्ञापक डेटाबेस अभिज्ञापक असू शकतो, ज्यामुळे स्क्रीनशॉटला विशिष्ट डेटाबेस रेकॉर्डशी संबद्ध होऊ दिले जाते.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setCustomId("123456");

grabzIt.URLToTable("https://www.tesla.com", options);
//Then call the Save method
grabzIt.Save("http://www.example.com/handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setCustomId("123456");

grabzIt.HTMLToTable("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the Save method
grabzIt.Save("http://www.example.com/handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.setCustomId("123456");

grabzIt.FileToTable("example.html", options);
//Then call the Save method
grabzIt.Save("http://www.example.com/handler");