ایچ ٹی ایم ایل ٹیبلز کو تبدیل کرنے کے متعدد طریقے ہیں into JSON ، CSV اور ایکسل اسپریڈشیٹ استعمال کریں GrabzIt's Node.js API، کچھ مفید تکنیک یہاں تفصیلی ہیں۔ تاہم ، اس سے پہلے کہ آپ فون کریں ، یاد رکھیں url_to_table, html_to_table or file_to_table طریقوں save or save_to میز پر قبضہ کرنے کے ل method طریقہ کو بلایا جانا چاہئے۔ اگر آپ جلدی دیکھنا چاہتے ہیں کہ آیا یہ خدمت آپ کے لئے ٹھیک ہے یا نہیں ، آپ کوشش کر سکتے ہیں HTML ٹیبلوں پر قبضہ کرنے کا براہ راست ڈیمو ایک URL سے۔
یہ خاص طریقہ کال مخصوص URL کے ویب پیج میں پہلی HTML ٹیبل کو تبدیل کردے گا ، into CSV دستاویز۔ اس کوڈ کا ٹکڑا کسی مخصوص ویب صفحے یا HTML ان پٹ میں پائے جانے والے پہلے HTML ٹیبل کو تبدیل کرے گا into CSV دستاویز۔
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
پہلے سے طے شدہ طور پر یہ پہلا جدول جس میں اس کی شناخت ہوتی ہے اسے تبدیل کردے گا intOA میز. تاہم ویب پیج میں موجود دوسری ٹیبل کو 2 پاس کرکے تبدیل کیا جاسکتا ہے 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
ایسی خاصیت جو یقینی بنائے گی کہ مخصوص عنصر ID کے اندر صرف ٹیبلز کو تبدیل کیا جائے گا۔
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; } });
Node.js اور GrabzIt استعمال کرکے آپ HTML ٹیبل کو تبدیل کرسکتے ہیں intاے JSON ، ذرا بتائیں json
فارمیٹ پیرامیٹر میں۔ جیسا کہ ایک بار ذیل میں مثال میں دکھایا گیا ہے save_to
طریقہ کار ختم ہو گیا ہے تو نامکمل فنکشن کو JSON کے ساتھ بلایا جاتا ہے جس کے نتیجے میں متغیر ہوتا ہے اور اس کے بعد inbuilt Node.js کے ذریعہ اس کی تجزیہ کرتا ہے۔ JSON.parse
کسی ایسی چیز کو تخلیق کرنے کا فنکشن جو HTML ٹیبل کی نمائندگی کرتا ہے۔
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; } });