HTML ਟੇਬਲ ਬਦਲਣ ਦੇ ਕਈ ਤਰੀਕੇ ਹਨ into ਜੇ ਐਸ ਐੱਨ, ਸੀ ਐੱਸ ਵੀ ਅਤੇ ਐਕਸਲ ਸਪਰੈਡਸ਼ੀਟ ਵਰਤਦੇ ਹੋਏ ਗਰੈਬਜ਼ੀਟ ਦਾ ਜਾਵਾ ਏਪੀਆਈ, ਇੱਥੇ ਵਿਸਤ੍ਰਿਤ ਕੁਝ ਸਭ ਤੋਂ ਲਾਭਦਾਇਕ ਤਕਨੀਕਾਂ ਹਨ. ਪਰ ਤੁਹਾਨੂੰ ਸ਼ੁਰੂ ਕਰਨ ਤੋਂ ਪਹਿਲਾਂ ਯਾਦ ਰੱਖੋ ਕਿ ਫੋਨ ਕਰਨ ਤੋਂ ਬਾਅਦ URLToTable, HTMLToTable or ਫਾਈਲ ਟੋਟੇਬਲ theੰਗ Save or SaveTo ਟੇਬਲ ਨੂੰ ਹਾਸਲ ਕਰਨ ਲਈ methodੰਗ ਨੂੰ ਬੁਲਾਇਆ ਜਾਣਾ ਚਾਹੀਦਾ ਹੈ. ਜੇ ਤੁਸੀਂ ਜਲਦੀ ਦੇਖਣਾ ਚਾਹੁੰਦੇ ਹੋ ਕਿ ਇਹ ਸੇਵਾ ਤੁਹਾਡੇ ਲਈ ਸਹੀ ਹੈ ਜਾਂ ਨਹੀਂ, ਤੁਸੀਂ ਕੋਸ਼ਿਸ਼ ਕਰ ਸਕਦੇ ਹੋ HTML ਟੇਬਲ ਕੈਪਚਰ ਕਰਨ ਦਾ ਸਿੱਧਾ ਪ੍ਰਦਰਸ਼ਨ ਇੱਕ ਯੂਆਰਐਲ ਤੋਂ.
ਇਹ ਕੋਡ ਸਨਿੱਪਟ ਇੱਕ ਦਿੱਤੇ ਵੈੱਬ ਪੇਜ ਵਿੱਚ ਪਾਈ ਪਹਿਲੀ HTML ਟੇਬਲ ਨੂੰ ਬਦਲ ਦੇਵੇਗਾ 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 ਕਲਾਸ.
setTableNumberToInclude
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 ensureੰਗ ਇਹ ਨਿਸ਼ਚਤ ਕਰਨ ਲਈ ਕਿ ਨਿਰਧਾਰਤ ਐਲੀਮੈਂਟ ਆਈਡੀ ਦੇ ਅੰਦਰ ਸਿਰਫ ਟੇਬਲ ਬਦਲ ਦਿੱਤੇ ਜਾਣਗੇ.
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 ਵਿਧੀ, ਹਾਲਾਂਕਿ ਇਹ ਸਿਰਫ XLSX ਅਤੇ JSON ਫਾਰਮੈਟਾਂ ਨਾਲ ਕੰਮ ਕਰੇਗੀ. ਇਹ ਵਿਕਲਪ ਤਿਆਰ ਕੀਤੀ ਸਪਰੈਡਸ਼ੀਟ ਵਰਕਬੁੱਕ ਦੇ ਅੰਦਰ ਹਰੇਕ ਟੇਬਲ ਨੂੰ ਇੱਕ ਨਵੀਂ ਸ਼ੀਟ ਵਿੱਚ ਪਾ ਦੇਵੇਗਾ.
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");
ਗਰੈਬਜ਼ਆਈਟ ਵੈਬ ਉੱਤੇ ਪਾਈ ਗਈ HTML ਟੇਬਲ ਨੂੰ ਜੇਐਸਓਐਨ ਵਿੱਚ ਵੀ ਬਦਲ ਸਕਦਾ ਹੈ, ਇਸ ਦੀ ਬਜਾਏ ਜੇਐਸਓਐਨ ਫਾਰਮੈਟ ਦਿਓ. ਹੇਠਾਂ ਦਿੱਤੀ ਉਦਾਹਰਣ ਵਿੱਚ ਡੇਟਾ ਨੂੰ ਸਮਕਾਲੀ ਨਾਲ ਪੜ੍ਹਿਆ ਜਾਂਦਾ ਹੈ ਅਤੇ ਏ ਦੇ ਰੂਪ ਵਿੱਚ ਵਾਪਸ ਕੀਤਾ ਜਾਂਦਾ ਹੈ GrabzItFile ਦੀ ਵਰਤੋਂ ਕਰਕੇ ਇਕਾਈ SaveTo methodੰਗ, ਹਾਲਾਂਕਿ ਆਮ ਤੌਰ 'ਤੇ ਇਹ ਸਿਫਾਰਸ਼ ਕੀਤੀ ਜਾਂਦੀ ਹੈ ਕਿ ਤੁਸੀਂ ਅਜਿਹਾ ਕਰੋ ਅਸਿੰਕਰੋਨੋਜੀ ਨਾਲ.
GrabzItFile
SaveTo
ਜਦੋਂ ਪਰਿਵਰਤਨ ਪੂਰਾ ਹੋ ਜਾਂਦਾ ਹੈ toString methodੰਗ ਨੂੰ JSON ਪ੍ਰਾਪਤ ਕਰਨ ਲਈ ਕਿਹਾ ਜਾਂਦਾ ਹੈ string, ਇਸ ਨੂੰ ਫਿਰ ਇੱਕ ਲਾਇਬ੍ਰੇਰੀ ਦੁਆਰਾ ਪਾਰਸ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ ਗੂਗਲ ਗੈਸਨ.
toString
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(); }
ਤੁਸੀਂ ਇੱਕ ਕਸਟਮ ਪਛਾਣਕਰਤਾ ਨੂੰ ਪਾਸ ਕਰ ਸਕਦੇ ਹੋ ਸਾਰਣੀ ਵਿੱਚ shownੰਗ ਜਿਵੇਂ ਕਿ ਹੇਠਾਂ ਦਰਸਾਇਆ ਗਿਆ ਹੈ, ਇਹ ਮੁੱਲ ਫਿਰ ਤੁਹਾਡੇ ਗਰੈਬਜ਼ੀਟ ਜਾਵਾ ਹੈਂਡਲਰ ਨੂੰ ਵਾਪਸ ਕਰ ਦਿੱਤਾ ਜਾਵੇਗਾ. ਉਦਾਹਰਣ ਦੇ ਲਈ ਇਹ ਕਸਟਮ ਪਛਾਣਕਰਤਾ ਇੱਕ ਡੇਟਾਬੇਸ ਪਛਾਣਕਰਤਾ ਹੋ ਸਕਦਾ ਹੈ, ਜਿਸ ਨਾਲ ਸਕ੍ਰੀਨਸ਼ਾਟ ਨੂੰ ਕਿਸੇ ਵਿਸ਼ੇਸ਼ ਡਾਟਾਬੇਸ ਰਿਕਾਰਡ ਨਾਲ ਜੋੜਿਆ ਜਾ ਸਕਦਾ ਹੈ.
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");