वेब कॅप्चर आणि रूपांतरित करण्यासाठी साधने

वेबसाइट्स वरून PHP सह HTML सारण्या कॅप्चर करा

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

डीफॉल्टनुसार हे त्यास ओळखत असलेल्या प्रथम सारणीचे रुपांतर करेल intओए टेबल. तथापि वेब पृष्ठामधील दुसरी सारणी एक्सएनयूएमएक्सला पास करून रूपांतरित केली जाऊ शकते 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 निर्दिष्ट घटक आयडीमधील केवळ सारणी रूपांतरित केली जातील याची खात्री करण्यासाठी पद्धत.

$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 टेबल्स वाचण्याची आवश्यकता असते, GrabzIt आपल्याला ऑनलाइन HTML टेबलांचे रुपांतर करून पीएचपीचा वापर करुन ते सक्षम करते. intओ जेएसओएन. हे निर्दिष्ट करण्यासाठी json स्वरूपन पॅरामीटर म्हणून. उदाहरणार्थ खालील उदाहरणामध्ये आपण एक HTML टेबल रूपांतरित करीत आहोत समक्रमितपणे मग इनबिल्ट वापरुन json_decode JSON विश्लेषित करण्यासाठी PHP पद्धत 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 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->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");