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

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

पर्ल एपीआय

एचटीएमएल टेबल्स रूपांतरित कशी करावी यासाठी खालील उदाहरणे वापरा into जेएसओएन, सीएसव्ही आणि एक्सेल स्प्रेडशीट वापरुन 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

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

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

एचटीएमएल टेबल्सला जेएसओएन मध्ये रूपांतरित करा

पर्ल आणि ग्रॅबझिटसह आपण आढळलेल्या एचटीएमएल सारण्या रूपांतरित करू शकता intओ जेएसओएन. प्रारंभ करण्यासाठी निर्दिष्ट करा json फॉरमॅट पॅरामीटर मध्ये उदाहरणार्थ आम्ही एक बनवत आहोत सिंक्रोनस कॉल वापरून SaveTo पध्दत, जे जेएसओएन परत करत आहे 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");