এইচটিএমএল টেবিল রূপান্তর করার একাধিক উপায় রয়েছে into জেএসএন, সিএসভি এবং এক্সেল স্প্রেডশিট ব্যবহার করে গ্র্যাবিজআইটির এএসপি.নেট এপিআই, বিশদটি এখানে বেশ কয়েকটি দরকারী কৌশল রয়েছে। তবে আপনি শুরু করার আগে মনে রাখবেন যে ফোন করার পরে URLToTable, HTMLToTable or FileToTable পদ্ধতিগুলি Save or SaveTo টেবিলটি ক্যাপচারের জন্য পদ্ধতিটি কল করতে হবে। আপনি যদি এই পরিষেবাটি আপনার জন্য উপযুক্ত কিনা তা দ্রুত দেখতে চান তবে আপনি এটিকে চেষ্টা করতে পারেন এইচটিএমএল টেবিলগুলি ক্যাপচারের লাইভ ডেমো একটি ইউআরএল থেকে।
নিম্নলিখিত কোড উদাহরণটি একটি নির্দিষ্ট ওয়েবপৃষ্ঠায় প্রথম এইচটিএমএল টেবিলকে রূপান্তর করে 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ওএ টেবিল তবে একটি ওয়েব পৃষ্ঠার দ্বিতীয় টেবিলটি 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
বৈশিষ্ট্য যা নির্দিষ্ট উপাদান আইডির মধ্যে কেবল সারণীগুলি রূপান্তরিত করবে তা নিশ্চিত করা হবে।
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 ফর্ম্যাট দিয়ে কাজ করবে। আপনি যদি এক্সএসএলএক্স ফর্ম্যাটটি চয়ন করেন তবে প্রতিটি সারণী উত্পন্ন স্প্রেডশিট ওয়ার্কবুকের মধ্যে একটি নতুন শীটে রাখা হবে।
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 এইচটিএমএল টেবিলগুলিও JSON এ রূপান্তর করতে পারে, কেবল নীচের মত JSON ফর্ম্যাট নির্দিষ্ট করুন। এখানে আমরা তথ্য সিঙ্ক্রোনালি পড়ছি intও GrabzItFile
ব্যবহার করে আপত্তি SaveTo
পদ্ধতি, তবে সাধারণত এটি করার পরামর্শ দেওয়া হয় অ্যাসিঙ্ক্রোনাস পরিবর্তে.
আমরা ফলাফল একবার পেয়েছি আমরা string ফোন করে JSON ফাইলের উপস্থাপনা ToString
পদ্ধতি, এটি পরে deserialized করা যেতে পারে intoa আপনার প্রিয় 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(); }
আপনি একটি কাস্টম সনাক্তকারী পাস করতে পারেন টেবিল পদ্ধতিগুলি নীচে দেখানো হয়েছে, এই মানটি আপনার গ্র্যাবজিট এএসপি.এনইটি হ্যান্ডলারের কাছে ফিরে আসবে। উদাহরণস্বরূপ, এই কাস্টম শনাক্তকারী কোনও ডাটাবেস শনাক্তকারী হতে পারে, একটি স্ক্রিনশটকে একটি নির্দিষ্ট ডাটাবেস রেকর্ডের সাথে যুক্ত করতে দেয়।
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");