HTML 테이블 변환 into JSON, CSV 및 엑셀 스프레드 시트 GrabzIt는 루비 API입니다 동쪽은 여기에 표시된 예를 따르십시오. 그러나 시작하기 전에 전화를 한 후 url_to_table, html_to_table or file_to_table 방법 save or save_to 테이블을 캡처하려면 메소드를 호출해야합니다. 이 서비스가 귀하에게 적합한 지 신속하게 확인하려면 HTML 테이블 캡처 라이브 데모 URL에서.
아래 예제는 지정된 웹 페이지에서 첫 번째 HTML 테이블을 변환합니다. intoa CSV 문서.
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")
XLSX 형식을 사용하는 경우 웹 페이지에 true를 전달하여 모든 테이블을 캡처 할 수 있습니다. 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을 사용하면 Ruby에서 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 Ruby 핸들러로 리턴됩니다. 예를 들어이 사용자 지정 식별자는 데이터베이스 식별자 일 수 있으며 스크린 샷을 특정 데이터베이스 레코드와 연결할 수 있습니다.
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")