ایچ ٹی ایم ایل ٹیبلز کو تبدیل کرنے کے متعدد طریقے ہیں into JSON ، CSV اور ایکسل اسپریڈشیٹ استعمال کریں GrabzIt کا ASP.NET 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 پاس کرکے تبدیل کیا جاسکتا ہے TableNumberToInclude
جائیداد.
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); TableOptions options = new TableOptions(); options.TableNumberToInclude = 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.TableNumberToInclude = 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.TableNumberToInclude = 2; grabzIt.FileToTable("tables.html", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.csv");
آپ یہ بھی بیان کرسکتے ہیں TargetElement
ایسی خاصیت جو یقینی بنائے گی کہ مخصوص عنصر ID کے اندر صرف ٹیبلز کو تبدیل کیا جائے گا۔
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); TableOptions options = new TableOptions(); options.TargetElement = "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.TargetElement = "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.TargetElement = "stocks_table"; grabzIt.FileToTable("tables.html", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.csv");
متبادل کے طور پر آپ ویب پیج پر سارے ٹیبلز پر درست ہو کر قبضہ کرسکتے ہیں IncludeAllTables
پراپرٹی ، تاہم ، یہ صرف XLSX یا JSON فارمیٹ کے ساتھ کام کرے گا۔ اگر آپ XSLX فارمیٹ کا انتخاب کرتے ہیں تو ہر ٹیبل کو ایک نئی شیٹ میں تیار اسپریڈشیٹ ورک بک میں رکھا جائے گا۔
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); TableOptions options = new TableOptions(); options.Format = TableFormat.xlsx; options.IncludeAllTables = 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.Format = TableFormat.xlsx; options.IncludeAllTables = 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.Format = TableFormat.xlsx; options.IncludeAllTables = true; grabzIt.FileToTable("tables.html", options); //Then call the Save or SaveTo method grabzIt.SaveTo("result.xlsx");
GrabzIt HTML جدولوں کو JSON میں تبدیل بھی کرسکتا ہے ، صرف JSON فارمیٹ کی وضاحت کریں جیسا کہ ذیل میں دکھایا گیا ہے۔ یہاں ہم اعداد و شمار ہم وقت پڑھ رہے ہیں intاے GrabzItFile
کا استعمال کرتے ہوئے اعتراض SaveTo
طریقہ ، تاہم عام طور پر یہ تجویز کیا جاتا ہے کہ آپ یہ کریں متفقہ طور پر بجائے.
ایک بار جب ہم نتیجہ حاصل کریں تو ہمیں حاصل ہوجاتا ہے string فون کرکے JSON فائل کی نمائندگی کریں ToString
طریقہ ، اس کے بعد ڈیسیریلائز کیا جاسکتا ہے intآپ کی پسندیدہ JSON لائبریری کا استعمال کرتے ہوئے متحرک آبجیکٹ۔
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); TableOptions options = new TableOptions(); options.Format = TableFormat.json; options.TableNumberToInclude = 1; grabzIt.URLToTable("https://www.tesla.com", options); GrabzItFile file = grabzIt.SaveTo(); if (file != null) { string json = file.ToString(); }
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); TableOptions options = new TableOptions(); options.Format = TableFormat.json; options.TableNumberToInclude = 1; 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); GrabzItFile file = grabzIt.SaveTo(); if (file != null) { string json = file.ToString(); }
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); TableOptions options = new TableOptions(); options.Format = TableFormat.json; options.TableNumberToInclude = 1; grabzIt.FileToTable("tables.html", options); GrabzItFile file = grabzIt.SaveTo(); if (file != null) { string json = file.ToString(); }
آپ کو ایک کسٹم شناخت کنندہ پاس کرسکتے ہیں ٹیبل جیسا کہ ذیل میں دکھایا گیا ہے ، اس کی قیمت آپ کے GrabzIt ASP.NET ہینڈلر کو واپس کردی جاتی ہے۔ مثال کے طور پر یہ کسٹم شناخت کنندہ ایک ڈیٹا بیس شناخت کنندہ ہوسکتا ہے ، جس سے اسکرین شاٹ کو کسی خاص ڈیٹا بیس ریکارڈ کے ساتھ وابستہ کیا جاسکتا ہے۔
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); TableOptions options = new TableOptions(); options.CustomId = "123456"; grabzIt.URLToTable("https://www.tesla.com", options); //Then call the Save method grabzIt.Save("http://www.example.com/Home/Handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); TableOptions options = new TableOptions(); options.CustomId = "123456"; grabzIt.HTMLToTable("<html><body><h1>Hello World!</h1></body></html>", options); //Then call the Save method grabzIt.Save("http://www.example.com/Home/Handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); TableOptions options = new TableOptions(); options.CustomId = "123456"; grabzIt.FileToTable("example.html", options); //Then call the Save method grabzIt.Save("http://www.example.com/Home/Handler");