এইচটিএমএল টেবিল রূপান্তর করার একাধিক উপায় রয়েছে into সিএসভি এবং এক্সেল স্প্রেডশিট ব্যবহার করে গ্র্যাবসআইটির পাইথন এপিআই, বিশদটি এখানে বেশ কয়েকটি দরকারী কৌশল রয়েছে। তবে আপনি শুরু করার আগে মনে রাখবেন যে ফোন করার পরে URLToTable, HTMLToTable or FileToTable পদ্ধতিগুলি Save or SaveTo টেবিলটি ক্যাপচারের জন্য পদ্ধতিটি কল করতে হবে। আপনি যদি এই পরিষেবাটি আপনার জন্য উপযুক্ত কিনা তা দ্রুত দেখতে চান তবে আপনি এটিকে চেষ্টা করতে পারেন এইচটিএমএল টেবিলগুলি ক্যাপচারের লাইভ ডেমো একটি ইউআরএল থেকে।
নীচের কোড স্নিপেট স্বয়ংক্রিয়ভাবে একটি নির্দিষ্ট ওয়েবপৃষ্ঠায় প্রথম এইচটিএমএল টেবিলকে রূপান্তর করে intoa 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
ডিফল্টরূপে এটি সনাক্তকারী প্রথম টেবিলকে রূপান্তর করবে intওএ টেবিল তবে একটি ওয়েব পৃষ্ঠার দ্বিতীয় টেবিলটি 2 কে পাস করে রূপান্তর করতে পারে tableNumberToInclude
বৈশিষ্ট্যাবলী।
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.tableNumberToInclude = 2 grabzIt.URLToTable("https://www.tesla.com", options) # Then call the Save or SaveTo method grabzIt.SaveTo("result.csv")
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() 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")
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.tableNumberToInclude = 2 grabzIt.FileToTable("tables.html", options) # Then call the Save or SaveTo method grabzIt.SaveTo("result.csv")
আপনি নির্দিষ্ট করতে পারেন targetElement
বৈশিষ্ট্য যা নির্দিষ্ট উপাদান আইডির মধ্যে কেবল সারণীগুলি রূপান্তরিত হবে তা নিশ্চিত করবে।
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.targetElement = "stocks_table" grabzIt.URLToTable("https://www.tesla.com", options) # Then call the Save or SaveTo method grabzIt.SaveTo("result.csv")
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() 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")
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.targetElement = "stocks_table" grabzIt.FileToTable("tables.html", options) # Then call the Save or SaveTo method grabzIt.SaveTo("result.csv")
বিকল্প হিসাবে আপনি সত্যায়িত হয়ে ওয়েব পৃষ্ঠায় সমস্ত টেবিল ক্যাপচার করতে পারেন includeAllTables
বৈশিষ্ট্য, তবে এটি কেবল XLSX এবং JSON ফর্ম্যাটগুলির সাথে কাজ করবে। এই বিকল্পটি উত্পন্ন স্প্রেডশিট ওয়ার্কবুকের মধ্যে প্রতিটি টেবিলকে একটি নতুন শীটে রাখবে।
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.format = 'xlsx' options.includeAllTables = True grabzIt.URLToTable("https://www.tesla.com", options) # Then call the Save or SaveTo method grabzIt.SaveTo("result.xlsx")
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.format = '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")
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.format = 'xlsx' options.includeAllTables = True grabzIt.FileToTable("tables.html", options) # Then call the Save or SaveTo method grabzIt.SaveTo("result.xlsx")
পাইথন এবং গ্র্যাজআইটি-র এইচটিএমএল টেবিল রূপান্তর পরিষেবাটি আপনাকে HTML টেবিলগুলিতে রূপান্তর করতে সক্ষম করে intও জেএসওএন। নীচে প্রদর্শিত প্রথম পদক্ষেপটি নির্দিষ্ট করা to json
বিন্যাস প্যারামিটারে। তারপরে আমরা জেএসএন পাই string সিঙ্ক্রোনাস সাথে SaveTo
পদ্ধতি, তারপরে আপনি পাইথনের জন্য JSON রূপান্তর করতে আপনার প্রিয় JSON পার্সার ব্যবহার করতে পারেন string intOA অবজেক্ট
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.format = "json" options.tableNumberToInclude = 1 grabzIt.URLToTable("https://www.tesla.com", options) json = grabzIt.SaveTo()
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.format = "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) json = grabzIt.SaveTo()
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.format = "json" options.tableNumberToInclude = 1 grabzIt.FileToTable("tables.html", options) json = grabzIt.SaveTo()
আপনি একটি কাস্টম সনাক্তকারী পাস করতে পারেন টেবিল নীচে প্রদর্শিত পদ্ধতি হিসাবে, এই মানটি আপনার গ্র্যাবজিট পাইথন হ্যান্ডলারের কাছে ফিরে আসে। উদাহরণস্বরূপ, এই কাস্টম শনাক্তকারী কোনও ডাটাবেস শনাক্তকারী হতে পারে, একটি স্ক্রিনশটকে একটি নির্দিষ্ট ডাটাবেস রেকর্ডের সাথে যুক্ত করার অনুমতি দেয়।
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.customId = "123456" grabzIt.URLToTable("https://www.tesla.com", options) # Then call the Save method grabzIt.Save("http://www.example.com/handler.py")
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() 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/handler.py")
from GrabzIt import GrabzItTableOptions from GrabzIt import GrabzItClient grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItTableOptions.GrabzItTableOptions() options.customId = "123456" grabzIt.FileToTable("example.html", options) # Then call the Save method grabzIt.Save("http://www.example.com/handler.py")