ਵੈੱਬ ਨੂੰ ਕੈਪਚਰ ਅਤੇ ਕਨਵਰਟ ਕਰਨ ਲਈ ਟੂਲ

ਵੈਬਸਾਈਟਾਂ ਤੋਂ PHP ਨਾਲ HTML ਟੇਬਲ ਕੈਪਚਰ ਕਰੋ

PHP API

HTML ਟੇਬਲ ਬਦਲਣ ਦੇ ਕਈ ਤਰੀਕੇ ਹਨ into JSON, CSV ਜਾਂ ਐਕਸਲ ਸਪਰੈਡਸ਼ੀਟ ਵਰਤਦੇ ਹੋਏ GrabzIt ਦਾ PHP API, ਇੱਥੇ ਵਿਸਤ੍ਰਿਤ ਕੁਝ ਸਭ ਤੋਂ ਲਾਭਦਾਇਕ ਤਕਨੀਕਾਂ ਹਨ. ਪਰ ਤੁਹਾਨੂੰ ਸ਼ੁਰੂ ਕਰਨ ਤੋਂ ਪਹਿਲਾਂ ਯਾਦ ਰੱਖੋ ਕਿ ਫੋਨ ਕਰਨ ਤੋਂ ਬਾਅਦ URLToTable, HTMLToTable or ਫਾਈਲ ਟੋਟੇਬਲ theੰਗ Save or SaveTo ਟੇਬਲ ਨੂੰ ਹਾਸਲ ਕਰਨ ਲਈ methodੰਗ ਨੂੰ ਬੁਲਾਇਆ ਜਾਣਾ ਚਾਹੀਦਾ ਹੈ. ਜੇ ਤੁਸੀਂ ਜਲਦੀ ਦੇਖਣਾ ਚਾਹੁੰਦੇ ਹੋ ਕਿ ਇਹ ਸੇਵਾ ਤੁਹਾਡੇ ਲਈ ਸਹੀ ਹੈ ਜਾਂ ਨਹੀਂ, ਤੁਸੀਂ ਕੋਸ਼ਿਸ਼ ਕਰ ਸਕਦੇ ਹੋ HTML ਟੇਬਲ ਕੈਪਚਰ ਕਰਨ ਦਾ ਸਿੱਧਾ ਪ੍ਰਦਰਸ਼ਨ ਇੱਕ ਯੂਆਰਐਲ ਤੋਂ.

ਮੁ Optionsਲੇ ਚੋਣਾਂ

ਹੇਠਾਂ ਪਾਈ ਗਈ ਕੋਡ ਦੀ ਉਦਾਹਰਣ ਆਪਣੇ ਆਪ ਨਿਰਧਾਰਿਤ ਵੈਬਪੰਨੇ ਵਿੱਚ ਲੱਭੀ ਗਈ ਪਹਿਲੀ 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 ਵਿਧੀ

$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 ensureੰਗ ਇਹ ਨਿਸ਼ਚਤ ਕਰਨ ਲਈ ਕਿ ਨਿਰਧਾਰਤ ਐਲੀਮੈਂਟ ਆਈਡੀ ਦੇ ਅੰਦਰ ਸਿਰਫ ਟੇਬਲ ਬਦਲ ਦਿੱਤੇ ਜਾਣਗੇ.

$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 ਟੇਬਲ ਨੂੰ ਪ੍ਰੋਗ੍ਰਾਮਿਕ ਤੌਰ ਤੇ ਪੜ੍ਹਨ ਦੀ ਜ਼ਰੂਰਤ ਹੁੰਦੀ ਹੈ, ਗਰੈਬਜ਼ ਆਈ ਟੀ ਐੱਮ ਐੱਚ ਟੀ ਐੱਮ ਟੇਬਲ ਨੂੰ ਕਨਵਰਟ ਕਰਨ ਦੁਆਰਾ ਪੀ ਐਚ ਪੀ ਦੀ ਵਰਤੋਂ ਕਰਦਿਆਂ ਅਜਿਹਾ ਕਰਨ ਦੇ ਯੋਗ ਕਰਦਾ ਹੈ. intਓ ਜੇ ਐਸ ਐੱਨ. ਇਹ ਨਿਰਧਾਰਤ ਕਰਨ ਲਈ json ਫਾਰਮੈਟ ਪੈਰਾਮੀਟਰ ਦੇ ਤੌਰ ਤੇ. ਉਦਾਹਰਣ ਲਈ ਹੇਠਾਂ ਦਿੱਤੀ ਉਦਾਹਰਣ ਵਿੱਚ ਅਸੀਂ ਇੱਕ HTML ਟੇਬਲ ਨੂੰ ਤਬਦੀਲ ਕਰ ਰਹੇ ਹਾਂ ਸਮਕਾਲੀ ਫਿਰ ਇਨਬਿਲਟ ਦੀ ਵਰਤੋਂ ਕਰਦੇ ਹੋਏ json_decode JSON ਨੂੰ ਪਾਰਸ ਕਰਨ ਲਈ PHP Pੰਗ string into ਇਕ ਅਜਿਹੀ ਚੀਜ਼ ਜਿਸ ਨਾਲ ਅਸਾਨੀ ਨਾਲ ਕੰਮ ਕਰ ਸਕਦੇ ਹਾਂ.

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

ਕਸਟਮ ਪਛਾਣਕਰਤਾ

ਤੁਸੀਂ ਇੱਕ ਕਸਟਮ ਪਛਾਣਕਰਤਾ ਨੂੰ ਪਾਸ ਕਰ ਸਕਦੇ ਹੋ ਸਾਰਣੀ ਵਿੱਚ shownੰਗ ਜਿਵੇਂ ਹੇਠਾਂ ਦਰਸਾਏ ਗਏ ਹਨ, ਇਹ ਮੁੱਲ ਤਦ ਤੁਹਾਡੇ ਗਰੈਬਜ਼ ਆਈ ਟੀ ਪੀ ਪੀ ਹੈਂਡਲਰ ਨੂੰ ਵਾਪਸ ਕਰ ਦਿੱਤਾ ਜਾਵੇਗਾ. ਉਦਾਹਰਣ ਦੇ ਲਈ ਇਹ ਕਸਟਮ ਪਛਾਣਕਰਤਾ ਇੱਕ ਡੇਟਾਬੇਸ ਪਛਾਣਕਰਤਾ ਹੋ ਸਕਦਾ ਹੈ, ਇੱਕ ਐਕਸਟਰੈਕਟ ਟੇਬਲ ਨੂੰ ਇੱਕ ਵਿਸ਼ੇਸ਼ ਡਾਟਾਬੇਸ ਰਿਕਾਰਡ ਨਾਲ ਜੋੜਨ ਦੀ ਆਗਿਆ ਦਿੰਦਾ ਹੈ.

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