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

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

PHP, API

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

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

$options = new \GrabzIt\GrabzItTableOptions();
$options->setTableNumberToInclude(2);

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

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

$options = new \GrabzIt\GrabzItTableOptions();
$options->setTableNumberToInclude(2);

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

તમે પણ ઉપયોગ કરી શકો છો setTargetElement પદ્ધતિ એ સુનિશ્ચિત કરવા માટે કે ફક્ત ઉલ્લેખિત તત્વ ID ની અંદરના કોષ્ટકોને રૂપાંતરિત કરવામાં આવશે.

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

$options = new \GrabzIt\GrabzItTableOptions();
$options->setTargetElement("stocks_table");

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

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

$options = new \GrabzIt\GrabzItTableOptions();
$options->setTargetElement("stocks_table");

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

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

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

$options = new \GrabzIt\GrabzItTableOptions();
$options->setFormat('xlsx');
$options->setIncludeAllTables(true);

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

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

$options = new \GrabzIt\GrabzItTableOptions();
$options->setFormat('xlsx');
$options->setIncludeAllTables(true);

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

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

પ્રોગ્રામિક રૂપે HTML ટેબલો વાંચવાની જરૂરિયાત હોય છે, GrabzIt તમને HTMLનલાઇન એચટીએમએલ કોષ્ટકોને કન્વર્ટ કરીને PHP નો ઉપયોગ કરીને આ કરવા સક્ષમ બનાવે છે. intઓ JSON. આ સ્પષ્ટ કરવા માટે json ફોર્મેટ પરિમાણ તરીકે. ઉદાહરણ તરીકે નીચેના ઉદાહરણમાં આપણે એક HTML ટેબલને રૂપાંતરિત કરી રહ્યા છીએ સુમેળમાં પછી ઇનબિલ્ટનો ઉપયોગ કરીને json_decode JSON ને વિશ્લેષિત કરવા માટે PHP પદ્ધતિ string into anબ્જેક્ટ કે જેની સાથે આપણે સરળતાથી કામ કરી શકીએ છીએ.

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

$options = new \GrabzIt\GrabzItTableOptions();
$options->setFormat("json");
$options->setTableNumberToInclude(1);

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

$json = $grabzIt->SaveTo();
if ($json != null)
{
    $tableObj = json_decode($json);
}
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

$options = new \GrabzIt\GrabzItTableOptions();
$options->setFormat("json");
$options->setTableNumberToInclude(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();
if ($json != null)
{
    $tableObj = json_decode($json);
}
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
    
$options = new \GrabzIt\GrabzItTableOptions();
$options->setFormat("json");
$options->setTableNumberToInclude(1);

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

$json = $grabzIt->SaveTo();
if ($json != null)
{
    $tableObj = json_decode($json);
}

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

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

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

$options = new \GrabzIt\GrabzItTableOptions();
$options->setCustomId(123456);

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

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

$options = new \GrabzIt\GrabzItTableOptions();
$options->setCustomId(123456);

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