HTML કોષ્ટકોને રૂપાંતરિત કરી રહ્યું છે intઓ JSON, CSV અને એક્સેલ સ્પ્રેડશીટ્સ નો ઉપયોગ કરીને GrabzIt નું રૂબી API પૂર્વમાં ફક્ત અહીં બતાવેલ ઉદાહરણોને અનુસરો. જો કે તમે પ્રારંભ કરતા પહેલા યાદ રાખો કે ફોન કર્યા પછી 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
પદ્ધતિ. દાખલા તરીકે, 2 ને સ્પષ્ટ કરવાથી વેબ પૃષ્ઠમાં મળેલા બીજા કોષ્ટકમાં કન્વર્ટ થશે.
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
પદ્ધતિ કે જે સુનિશ્ચિત કરે છે કે નિર્દિષ્ટ તત્વ ID માંના ફક્ત કોષ્ટકોને રૂપાંતરિત કરવામાં આવશે.
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")
જો તમે એક્સએલએસએક્સ ફોર્મેટનો ઉપયોગ કરો છો, તો તમે વેબપેજ પરના બધા કોષ્ટકોને કેપ્ચર કરી શકો છો 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 આ સ્પષ્ટ કરવા માટે 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")