वेब कॅप्चर आणि रूपांतरित करण्यासाठी साधने

रूबीसह वेबसाइट्सवरून HTML सारण्या कॅप्चर करा

रुबी एपीआय

HTML सारण्या रुपांतरित करीत आहे into जेएसओएन, सीएसव्ही आणि एक्सेल स्प्रेडशीट वापरुन ग्रॅबझिटची रुबी एपीआय पूर्वेस येथे दर्शविलेल्या उदाहरणांचे अनुसरण करा. तथापि आपण सुरू करण्यापूर्वी लक्षात ठेवा की कॉल केल्यावर url_to_table, html_to_table or file_to_table पद्धती save or save_to टेबल कॅप्चर करण्यासाठी मेथड कॉल केला पाहिजे. ही सेवा आपल्यासाठी योग्य आहे की नाही हे आपण त्वरीत पाहू इच्छित असल्यास आपण प्रयत्न करू शकता एचटीएमएल टेबल्स कॅप्चर करण्याचा थेट डेमो URL वरून.

मूलभूत पर्याय

खाली दिलेली उदाहरणे निर्दिष्ट वेबपृष्ठामधील प्रथम HTML सारणी रूपांतरित करते intसीएसव्ही दस्तऐवज

grabzItClient.url_to_table("https://www.tesla.com")
# Then call the save or save_to method
grabzItClient.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
grabzItClient.file_to_table("tables.html")
# Then call the save or save_to method

आपण वेबपृष्ठामध्ये प्रथम सारणी स्वयंचलितपणे रूपांतरित करू इच्छित नसल्यास आपण निर्दिष्ट करू शकता tableNumberToInclude पद्धत. उदाहरणार्थ एक्सएनयूएमएक्स निर्दिष्ट करणे वेब पृष्ठामध्ये आढळणारी दुसरी सारणी रूपांतरित करेल.

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.tableNumberToInclude = 2

grabzItClient.url_to_table("https://www.tesla.com", options)
# Then call the save or save_to method
grabzItClient.save_to("result.csv"
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.tableNumberToInclude = 2

grabzItClient.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
grabzItClient.save_to("result.csv")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.tableNumberToInclude = 2

grabzItClient.file_to_table("tables.html", options)
# Then call the save or save_to method
grabzItClient.save_to("result.csv")

आपण निर्दिष्ट करू शकता targetElement निर्दिष्ट घटक आयडीमधील केवळ तक्त्यांचे रूपांतरण सुनिश्चित करेल अशी पद्धत.

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.targetElement = "stocks_table"

grabzItClient.url_to_table("https://www.tesla.com", options)
# Then call the save or save_to method
grabzItClient.save_to("result.csv")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.targetElement = "stocks_table"

grabzItClient.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
grabzItClient.save_to("result.csv")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.targetElement = "stocks_table"

grabzItClient.file_to_table("tables.html", options)
# Then call the save or save_to method
grabzItClient.save_to("result.csv")

आपण XLSX स्वरूपन वापरल्यास आपण वेबपृष्ठावरील सर्व टेबल्स बरोबर नेऊन कॅप्चर करू शकता includeAllTables पद्धत. हे नंतर प्रत्येक सारणी नवीन पत्रकात स्प्रेडशीट वर्कबुकमध्ये ठेवेल.

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.format = "xlsx"
options.includeAllTables = true

grabzItClient.url_to_table("https://www.tesla.com", options)
# Then call the save or save_to method
grabzItClient.save_to("result.xlsx")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.format = "xlsx"
options.includeAllTables = true

grabzItClient.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
grabzItClient.save_to("result.xlsx")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.format = "xlsx"
options.includeAllTables = true

grabzItClient.file_to_table("tables.html", options)
# Then call the save or save_to method
grabzItClient.save_to("result.xlsx")

एचटीएमएल टेबल्सला जेएसओएन मध्ये रूपांतरित करा

GrabzIt सह, रुबी सहजपणे HTML सारण्या रूपांतरित करू शकते intहे जेएसओएन निर्दिष्ट करण्यासाठी json फॉरमॅट पॅरामीटर मध्ये खाली दिलेल्या उदाहरणात डेटा वाचला आहे समक्रमितपणे वापरून save_to पद्धत म्हणून, एक म्हणून JSON मिळविण्यासाठी string. हे नंतर यासारख्या लायब्ररीद्वारे विश्लेषित केले जाऊ शकते json रत्न.

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.format = "json"
options.tableNumberToInclude = 1

grabzItClient.url_to_table("https://www.tesla.com", options)

json = grabzItClient.save_to()
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.format = "json"
options.tableNumberToInclude = 1

grabzItClient.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)

json = grabzItClient.save_to()
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.format = "json"
options.tableNumberToInclude = 1

grabzItClient.file_to_table("tables.html", options)

json = grabzItClient.save_to()

सानुकूल अभिज्ञापक

आपण एक सानुकूल अभिज्ञापक पास करू शकता टेबल खाली दर्शविल्या गेलेल्या पद्धती, हे मूल्य नंतर आपल्या GrabzIt रुबी हँडलरला परत केले जाईल. उदाहरणार्थ हा सानुकूल अभिज्ञापक डेटाबेस अभिज्ञापक असू शकतो, ज्यामुळे स्क्रीनशॉटला विशिष्ट डेटाबेस रेकॉर्डशी संबद्ध होऊ दिले जाते.

grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.customId = "123456"

grabzItClient.url_to_table("https://www.tesla.com", options)
# Then call the save method
grabzItClient.save("http://www.example.com/handler/index")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.customId = "123456"

grabzItClient.html_to_table("<html><body><h1>Hello World!</h1></body></html>", options)
# Then call the save method
grabzItClient.save("http://www.example.com/handler/index")
grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")

options = GrabzIt::TableOptions.new()
options.customId = "123456"

grabzItClient.file_to_table("example.html", options)
# Then call the save method
grabzItClient.save("http://www.example.com/handler/index")