એચટીએમએલ કોષ્ટકોને રૂપાંતરિત કરવાની ઘણી રીતો છે intઓ JSON, CSV અને એક્સેલ સ્પ્રેડશીટ્સ નો ઉપયોગ કરીને GrabzIt ની Node.js API, અહીં વિગતવાર કેટલીક સૌથી ઉપયોગી તકનીકો છે. જો કે તમે પ્રારંભ કરતા પહેલા યાદ રાખો કે ફોન કર્યા પછી url_to_table, html_to_table or file_to_table પદ્ધતિઓ save or save_to ટેબલને કેપ્ચર કરવા માટે પદ્ધતિ કહેવી આવશ્યક છે. જો તમે ઝડપથી જોવા માંગતા હો કે આ સેવા તમારા માટે યોગ્ય છે કે નહીં, તો તમે એક પ્રયાસ કરી શકો છો એચટીએમએલ કોષ્ટકો કબજે લાઇવ ડેમો એક URL માંથી.
આ વિશિષ્ટ મેથડ ક callલ, યુઆરએલના વેબપેજ પરના પ્રથમ HTML ટેબલને કન્વર્ટ કરશે, intસીએસવી દસ્તાવેજ. આ કોડ સ્નિપેટ નિર્દિષ્ટ વેબપેજ અથવા એચટીએમએલ ઇનપુટમાં મળેલા પ્રથમ HTML ટેબલને કન્વર્ટ કરશે intસીએસવી દસ્તાવેજ.
client.url_to_table("https://www.tesla.com"); //Then call the save or save_to method
client.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
client.file_to_table("tables.html"); //Then call the save or save_to method
ડિફ defaultલ્ટ રૂપે આ તે ઓળખાતા પહેલા કોષ્ટકમાં રૂપાંતરિત થશે intઓએ ટેબલ. જો કે વેબ પૃષ્ઠમાંનો બીજો કોષ્ટક એક 2 પસાર કરીને રૂપાંતરિત કરી શકાય છે tableNumberToInclude
મિલકત
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"tableNumberToInclude":2}; client.url_to_table("https://www.tesla.com", options); //Then call the save or save_to method client.save_to("result.csv", function (error, id){ //this callback is called once the capture is downloaded if (error != null){ throw error; } });
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"tableNumberToInclude":2}; client.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 client.save_to("result.csv", function (error, id){ //this callback is called once the capture is downloaded if (error != null){ throw error; } });
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"tableNumberToInclude":2}; client.file_to_table("tables.html", options); //Then call the save or save_to method client.save_to("result.csv", function (error, id){ //this callback is called once the capture is downloaded if (error != null){ throw error; } });
તમે પણ સ્પષ્ટ કરી શકો છો targetElement
પ્રોપર્ટી કે જે નિર્ધારિત તત્વ ID માં ફક્ત કોષ્ટકોને રૂપાંતરિત કરશે તેની ખાતરી કરશે.
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"targetElement":"stocks_table"}; client.url_to_table("https://www.tesla.com", options); //Then call the save or save_to method client.save_to("result.csv", function (error, id){ //this callback is called once the capture is downloaded if (error != null){ throw error; } });
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"targetElement":"stocks_table"}; client.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 client.save_to("result.csv", function (error, id){ //this callback is called once the capture is downloaded if (error != null){ throw error; } });
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"targetElement":"stocks_table"}; client.file_to_table("tables.html", options); //Then call the save or save_to method client.save_to("result.csv", function (error, id){ //this callback is called once the capture is downloaded if (error != null){ throw error; } });
વૈકલ્પિક રૂપે તમે વેબ પેજ પરનાં બધા કોષ્ટકોને કેપ્ચર કરી શકો છો includeAllTables
પ્રોપર્ટી, જો કે આ ફક્ત JSON અને XLSX ફોર્મેટ્સ સાથે કાર્ય કરશે. આ વિકલ્પ જનરેટ કરેલી સ્પ્રેડશીટ વર્કબુકમાં દરેક કોષ્ટકને નવી શીટમાં મૂકશે.
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"format","xlsx","includeHeaderNames":true,"includeAllTables":true}; client.url_to_table("https://www.tesla.com", options); //Then call the save or save_to method client.save_to("result.xlsx", function (error, id){ //this callback is called once the capture is downloaded if (error != null){ throw error; } });
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"format","xlsx","includeHeaderNames":true,"includeAllTables":true}; client.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 client.save_to("result.xlsx", function (error, id){ //this callback is called once the capture is downloaded if (error != null){ throw error; } });
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"format","xlsx","includeHeaderNames":true,"includeAllTables":true}; client.file_to_table("tables.html", options); //Then call the save or save_to method client.save_to("result.xlsx", function (error, id){ //this callback is called once the capture is downloaded if (error != null){ throw error; } });
નોડ.જેએસ અને ગ્રrabબ્સટનો ઉપયોગ કરીને તમે એચટીએમએલ કોષ્ટકોને કન્વર્ટ કરી શકો છો intઓ JSON, ફક્ત સ્પષ્ટ કરો json
બંધારણના પરિમાણમાં. એકવાર નીચેના ઉદાહરણમાં બતાવ્યા પ્રમાણે save_to
મેથડ સમાપ્ત થઈ ગઈ છે, અપૂર્ણ કાર્યને JSON સાથે કહેવામાં આવે છે પરિણામ વેરીએબલમાં આ પછી ઇનબિલ્ટ નોડ.જે દ્વારા પાર્સ કરવામાં આવે છે. JSON.parse
એચટીએમએલ ટેબલ રજૂ કરે છે તે thatબ્જેક્ટ બનાવવા માટે ફંક્શન.
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"format","json","includeHeaderNames":true,"includeAllTables":true}; client.url_to_table("https://www.tesla.com", options); client.save_to(null, function(error, result){ if (result != null) { var tableObj = JSON.parse(result); } });
તમે કસ્ટમ ઓળખાણકર્તાને પાસ કરી શકો છો ટેબલ નીચે બતાવેલ પદ્ધતિઓ, આ મૂલ્ય પછી તમારા GrabzIt Node.js હેન્ડલર પર પાછા ફર્યા છે. હમણાં પૂરતું આ કસ્ટમ આઇડેન્ટિફાયર ડેટાબેસ ઓળખકર્તા હોઈ શકે છે, સ્ક્રીનશ .ટને ચોક્કસ ડેટાબેઝ રેકોર્ડ સાથે જોડવાની મંજૂરી આપે છે.
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"customId":123456}; client.url_to_table("https://www.tesla.com", options); //Then call the save method client.save("http://www.example.com/handler", function (error, id){ if (error != null){ throw error; } });
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"customId":123456}; client.html_to_table("<html><body><h1>Hello World!</h1></body></html>", options); //Then call the save method client.save("http://www.example.com/handler", function (error, id){ if (error != null){ throw error; } });
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); var options = {"customId":123456}; client.file_to_table("example.html", options); //Then call the save method client.save("http://www.example.com/handler", function (error, id){ if (error != null){ throw error; } });