ویب پر گرفت اور تبدیل کرنے کے اوزار

جاوا کے ساتھ ویب سائٹس سے ایچ ٹی ایم ایل ٹیبلس پر قبضہ کریں

جاوا API

ایچ ٹی ایم ایل ٹیبلز کو تبدیل کرنے کے متعدد طریقے ہیں into JSON ، CSV اور ایکسل اسپریڈشیٹ استعمال کریں GrabzIt کا جاوا API، کچھ مفید تکنیک یہاں تفصیلی ہیں۔ تاہم ، اس سے پہلے کہ آپ فون کریں ، یاد رکھیں URLToTable, HTMLToTable or فائلٹوٹوبل طریقوں Save or SaveTo میز پر قبضہ کرنے کے ل method طریقہ کو بلایا جانا چاہئے۔ اگر آپ جلدی دیکھنا چاہتے ہیں کہ آیا یہ خدمت آپ کے لئے ٹھیک ہے یا نہیں ، آپ کوشش کر سکتے ہیں HTML ٹیبلوں پر قبضہ کرنے کا براہ راست ڈیمو ایک URL سے۔

بنیادی اختیارات

اس کوڈ کا ٹکڑا کسی مخصوص ویب صفحے میں پائے جانے والے پہلے HTML ٹیبل میں تبدیل ہوجائے گا into CSV دستاویز۔

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

پہلے سے طے شدہ طور پر یہ پہلا جدول جس میں اس کی شناخت ہوتی ہے اسے تبدیل کردے گا intOA میز. تاہم ویب پیج میں موجود دوسری ٹیبل کو 2 پاس کرکے تبدیل کیا جاسکتا ہے 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 اس بات کا یقین کرنے کا طریقہ کہ مخصوص عنصر کی ID کے اندر صرف ٹیبلز کو تبدیل کیا جائے گا۔

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");

HTML میزیں JSON میں تبدیل کریں

GrabzIt ویب پر پائے جانے والے HTML جدولوں کو JSON میں تبدیل بھی کرسکتا ہے ، بجائے اس کے بجائے JSON فارمیٹ کی وضاحت کریں۔ مثال کے طور پر ذیل میں اعداد و شمار کو بیک وقت پڑھا جاتا ہے اور بطور a GrabzItFile کا استعمال کرتے ہوئے اعتراض SaveTo طریقہ ، تاہم عام طور پر یہ تجویز کیا جاتا ہے کہ آپ یہ کریں متفقہ طور پر.

جب تبادلہ مکمل ہوجائے toString JSON حاصل کرنے کے ل method طریقہ کو کہا جاتا ہے 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");