ویب پر گرفت اور تبدیل کرنے کے اوزار

پی ایچ پی کی مدد سے ویب سائٹس سے ایچ ٹی ایم ایل ٹیبل پر قبضہ کریں

پی ایچ پی کی API

ایچ ٹی ایم ایل ٹیبلز کو تبدیل کرنے کے متعدد طریقے ہیں into JSON ، CSV یا ایکسل اسپریڈشیٹ استعمال کریں GrabzIt کا پی ایچ پی API، کچھ مفید تکنیک یہاں تفصیلی ہیں۔ تاہم ، اس سے پہلے کہ آپ فون کریں ، یاد رکھیں URLToTable, HTMLToTable or فائلٹوٹوبل طریقوں Save or SaveTo میز پر قبضہ کرنے کے ل method طریقہ کو بلایا جانا چاہئے۔ اگر آپ جلدی دیکھنا چاہتے ہیں کہ آیا یہ خدمت آپ کے لئے ٹھیک ہے یا نہیں ، آپ کوشش کر سکتے ہیں HTML ٹیبلوں پر قبضہ کرنے کا براہ راست ڈیمو ایک URL سے۔

بنیادی اختیارات

ذیل میں ملنے والا کوڈ کی مثال خود بخود پہلے ویب ٹیبل کو کسی مخصوص ویب صفحہ میں دریافت کرتی ہے into CSV دستاویز۔

$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

پہلے سے طے شدہ طور پر یہ پہلا جدول جس میں اس کی شناخت ہوتی ہے اسے تبدیل کردے گا intOA میز. تاہم ویب پیج میں موجود دوسری ٹیبل کو 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 ٹیبل کو تبدیل کرکے پی ایچ پی کا استعمال کرکے یہ کرنے کے قابل بناتا ہے۔ intO JSON۔ اس کی وضاحت کرنے کے لئے json فارمیٹ پیرامیٹر کے طور پر مثال کے طور پر ذیل میں ہم ایک HTML ٹیبل تبدیل کررہے ہیں ہم وقت سازی کے ساتھ پھر inbuilt کا استعمال کرتے ہوئے json_decode JSON کو پارس کرنے کے لئے پی ایچ پی کا طریقہ 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);
}

کسٹم شناختی

آپ کو ایک کسٹم شناخت کنندہ پاس کرسکتے ہیں ٹیبل جیسا کہ ذیل میں دکھایا گیا ہے ، اس کی قیمت آپ کے GrabzIt پی ایچ پی ہینڈلر کو واپس کردی جاتی ہے۔ مثال کے طور پر یہ کسٹم شناخت کنندہ ایک ڈیٹا بیس کا شناخت کنندہ ہوسکتا ہے ، جس سے نکالا ہوا ٹیبل کسی خاص ڈیٹا بیس ریکارڈ سے وابستہ ہوسکتا ہے۔

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