এইচটিএমএল টেবিল রূপান্তর করার একাধিক উপায় রয়েছে 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 কে পাস করে রূপান্তর করতে পারে 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
পদ্ধতি, তবে এটি কেবল এক্সএলএসএক্স এবং জেএসএন ফর্ম্যাটগুলির সাথে কাজ করবে। এই বিকল্পটি উত্পন্ন স্প্রেডশিট ওয়ার্কবুকের মধ্যে প্রতিটি টেবিলকে একটি নতুন শীটে রাখবে।
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");
GrabzIt ওয়েবে পাওয়া HTML টি টেবিলগুলি JSON এ রূপান্তর করতে পারে, কেবল পরিবর্তে JSON ফর্ম্যাটটি নির্দিষ্ট করুন। নীচের উদাহরণে ডেটা সিঙ্ক্রোনাসলি পড়ে এবং এ হিসাবে ফিরে আসে is 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(); }
আপনি একটি কাস্টম সনাক্তকারী পাস করতে পারেন টেবিল পদ্ধতিগুলি নীচে দেখানো হয়েছে, এই মানটি আপনার গ্র্যাবজিট জাভা হ্যান্ডলারের কাছে ফিরে আসবে। উদাহরণস্বরূপ, এই কাস্টম শনাক্তকারী কোনও ডাটাবেস শনাক্তকারী হতে পারে, একটি স্ক্রিনশটকে একটি নির্দিষ্ট ডাটাবেস রেকর্ডের সাথে যুক্ত করতে দেয়।
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");