વેબને કેપ્ચર અને કન્વર્ટ કરવા માટેનાં સાધનો

એએસપી.એન.ટી. સાથે વેબસાઈટસ પરથી એચટીએમએલ કોષ્ટકો કેપ્ચર કરો

ASP.NET API

એચટીએમએલ કોષ્ટકોને રૂપાંતરિત કરવાની ઘણી રીતો છે intઓ JSON, CSV અને એક્સેલ સ્પ્રેડશીટ્સ નો ઉપયોગ કરીને GrabzIt નું ASP.NET API, અહીં વિગતવાર કેટલીક સૌથી ઉપયોગી તકનીકો છે. જો કે તમે પ્રારંભ કરતા પહેલા યાદ રાખો કે ફોન કર્યા પછી URLToTable, HTMLToTable or ફાઇલટોટેબલ પદ્ધતિઓ Save or SaveTo ટેબલને કેપ્ચર કરવા માટે પદ્ધતિ કહેવી આવશ્યક છે. જો તમે ઝડપથી જોવા માંગતા હો કે આ સેવા તમારા માટે યોગ્ય છે કે નહીં, તો તમે એક પ્રયાસ કરી શકો છો એચટીએમએલ કોષ્ટકો કબજે લાઇવ ડેમો એક URL માંથી.

મૂળભૂત વિકલ્પો

નીચે આપેલ કોડ ઉદાહરણ સ્પષ્ટ વેબપેજમાં પ્રથમ 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

ડિફ defaultલ્ટ રૂપે આ તે ઓળખાતા પહેલા કોષ્ટકમાં રૂપાંતરિત થશે intઓએ ટેબલ. જો કે વેબ પૃષ્ઠમાંનો બીજો કોષ્ટક એક 2 પસાર કરીને રૂપાંતરિત કરી શકાય છે TableNumberToInclude મિલકત

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.TableNumberToInclude = 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.TableNumberToInclude = 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.TableNumberToInclude = 2;

grabzIt.FileToTable("tables.html", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv");

તમે પણ સ્પષ્ટ કરી શકો છો TargetElement પ્રોપર્ટી કે જે નિર્ધારિત તત્વ ID માં ફક્ત કોષ્ટકોને રૂપાંતરિત કરશે તેની ખાતરી કરશે.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.TargetElement = "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.TargetElement = "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.TargetElement = "stocks_table";

grabzIt.FileToTable("tables.html", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.csv");

વૈકલ્પિક રૂપે તમે વેબ પેજ પરનાં બધા કોષ્ટકોને કેપ્ચર કરી શકો છો IncludeAllTables પ્રોપર્ટી, જો કે આ ફક્ત XLSX અથવા JSON ફોર્મેટ સાથે કાર્ય કરશે. જો તમે XSLX ફોર્મેટ પસંદ કરો છો, તો દરેક કોષ્ટક જનરેટ કરેલી સ્પ્રેડશીટ વર્કબુકમાં નવી શીટમાં મૂકવામાં આવશે.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.Format = TableFormat.xlsx;
options.IncludeAllTables = 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.Format = TableFormat.xlsx;
options.IncludeAllTables = 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.Format = TableFormat.xlsx;
options.IncludeAllTables = true;

grabzIt.FileToTable("tables.html", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.xlsx");

HTML કોષ્ટકોને JSON માં કન્વર્ટ કરો

GrabzIt એચટીએમએલ કોષ્ટકોને પણ JSON માં કન્વર્ટ કરી શકે છે, નીચે બતાવ્યા પ્રમાણે JSON ફોર્મેટનો ઉલ્લેખ કરો. અહીં આપણે ડેટાને સુમેળમાં વાંચી રહ્યા છીએ intઓ GrabzItFile નો ઉપયોગ કરીને objectબ્જેક્ટ SaveTo પદ્ધતિ, જો કે સામાન્ય રીતે ભલામણ કરવામાં આવે છે કે તમે આ કરો અસુમેળ તેના બદલે

એકવાર આપણી પાસે પરિણામ આવે છે string ક callingલ કરીને JSON ફાઇલનું પ્રતિનિધિત્વ ToString પદ્ધતિ, આ પછી ડીસેરાઇઝેશન કરી શકાય છે intતમારી ગમતી JSON લાઇબ્રેરીનો ઉપયોગ કરીને એક ગતિશીલ objectબ્જેક્ટ.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.Format = TableFormat.json;
options.TableNumberToInclude = 1;

grabzIt.URLToTable("https://www.tesla.com", options);

GrabzItFile file = grabzIt.SaveTo();
if (file != null)
{
    string json = file.ToString();
}
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.Format = TableFormat.json;
options.TableNumberToInclude = 1;

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);

GrabzItFile file = grabzIt.SaveTo();
if (file != null)
{
    string json = file.ToString();
}
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.Format = TableFormat.json;
options.TableNumberToInclude = 1;

grabzIt.FileToTable("tables.html", options);

GrabzItFile file = grabzIt.SaveTo();
if (file != null)
{
    string json = file.ToString();
}

કસ્ટમ ઓળખકર્તા

તમે કસ્ટમ ઓળખાણકર્તાને પાસ કરી શકો છો ટેબલ નીચે બતાવેલ પદ્ધતિઓ, આ મૂલ્ય પછી તમારા GrabzIt ASP.NET હેન્ડલર પર પાછા ફર્યા છે. દાખલા તરીકે આ કસ્ટમ આઇડેન્ટિફાયર ડેટાબેસ ઓળખકર્તા હોઈ શકે છે, જેનાથી સ્ક્રીનશોટને કોઈ ચોક્કસ ડેટાબેઝ રેકોર્ડ સાથે સંકળાયેલ હોઈ શકે છે.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.CustomId = "123456";

grabzIt.URLToTable("https://www.tesla.com", options);
//Then call the Save method
grabzIt.Save("http://www.example.com/Home/Handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.CustomId = "123456";

grabzIt.HTMLToTable("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the Save method
grabzIt.Save("http://www.example.com/Home/Handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

TableOptions options = new TableOptions();
options.CustomId = "123456";

grabzIt.FileToTable("example.html", options);
//Then call the Save method
grabzIt.Save("http://www.example.com/Home/Handler");