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

પર્લ સાથે વેબસાઇટ્સથી એચટીએમએલ કોષ્ટકો મેળવો

પર્લ API

એચટીએમએલ કોષ્ટકોને કેવી રીતે રૂપાંતરિત કરવું તે નીચેના ઉદાહરણોનો ઉપયોગ કરો intઓ JSON, CSV અને એક્સેલ સ્પ્રેડશીટ્સ નો ઉપયોગ કરીને GrabzIt નું પર્લ 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 પદ્ધતિ

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

$options = GrabzItTableOptions->new();
$options->tableNumberToInclude(2);

$grabzIt->URLToTable("https://www.tesla.com", $options);
# Then call the Save or SaveTo method
$grabzIt->SaveTo("result.csv");
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

$options = GrabzItTableOptions->new();
$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");
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

$options = GrabzItTableOptions->new();
$options->tableNumberToInclude(2);

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

તમે પણ સ્પષ્ટ કરી શકો છો targetElement પદ્ધતિ કે જે સુનિશ્ચિત કરે છે કે નિર્દિષ્ટ તત્વ ID માંના ફક્ત કોષ્ટકોને રૂપાંતરિત કરવામાં આવશે.

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

$options = GrabzItTableOptions->new();
$options->targetElement("stocks_table");

$grabzIt->URLToTable("https://www.tesla.com", $options);
# Then call the Save or SaveTo method
$grabzIt->SaveTo("result.csv");
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

$options = GrabzItTableOptions->new();
$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");
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

$options = GrabzItTableOptions->new();
$options->targetElement("stocks_table");

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

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

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

$options = GrabzItTableOptions->new();
$options->format('xlsx');
$options->includeAllTables(1);

$grabzIt->URLToTable("https://www.tesla.com", $options);
# Then call the Save or SaveTo method
$grabzIt->SaveTo("result.xlsx");
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

$options = GrabzItTableOptions->new();
$options->format('xlsx');
$options->includeAllTables(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);
# Then call the Save or SaveTo method
$grabzIt->SaveTo("result.xlsx");
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

$options = GrabzItTableOptions->new();
$options->format('xlsx');
$options->includeAllTables(1);

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

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

પર્લ અને ગ્રrabબ્સ સાથે તમે મળેલા HTML કોષ્ટકોને કન્વર્ટ કરી શકો છો intઓ JSON. પ્રારંભ કરવા માટે સ્પષ્ટ કરો json બંધારણના પરિમાણમાં. ઉદાહરણમાં આપણે એ બનાવી રહ્યા છીએ સિંક્રનસ ક callલ નો ઉપયોગ કરીને SaveTo પદ્ધતિ, જે JSON પરત કરી રહી છે string, પછી આ જેવા લાઇબ્રેરી દ્વારા વિશ્લેષણ કરી શકાય છે જેએસઓન :: પાર્સ.

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

$options = GrabzItTableOptions->new();
$options->format("json");
$options->tableNumberToInclude(1);

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

$json = $grabzIt->SaveTo();
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

$options = GrabzItTableOptions->new();
$options->format("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);

$json = $grabzIt->SaveTo();
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

$options = GrabzItTableOptions->new();
$options->format("json");
$options->tableNumberToInclude(1);

$grabzIt->FileToTable("tables.html", $options);

$json = $grabzIt->SaveTo();

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

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

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

$options = GrabzItTableOptions->new();
$options->customId("123456");

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

$options = GrabzItTableOptions->new();
$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/handler.pl");
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");

$options = GrabzItTableOptions->new();
$options->customId("123456");

$grabzIt->FileToTable("example.html", $options);
# Then call the Save method
$grabzIt->Save("http://www.example.com/handler.pl");