ওয়েব ক্যাপচার এবং রূপান্তর করার সরঞ্জামসমূহ

পার্লের সাহায্যে ওয়েবসাইটগুলি থেকে এইচটিএমএল টেবিলগুলি ক্যাপচার করুন

পার্ল এপিআই

এইচটিএমএল টেবিলগুলি কীভাবে রূপান্তর করতে হয় তার নীচের উদাহরণগুলি ব্যবহার করুন into জেএসএন, সিএসভি এবং এক্সেল স্প্রেডশিট ব্যবহার করে গ্র্যাবসআইটির পার্ল এপিআই। তবে আপনি শুরু করার আগে মনে রাখবেন যে ফোন করার পরে URLToTable, HTMLToTable or FileToTable পদ্ধতিগুলি Save or SaveTo পদ্ধতি অবশ্যই টেবিল ক্যাপচার পুনরুদ্ধার করতে হবে। আপনি যদি এই পরিষেবাটি আপনার জন্য উপযুক্ত কিনা তা দ্রুত দেখতে চান তবে আপনি এটিকে চেষ্টা করতে পারেন এইচটিএমএল টেবিলগুলি ক্যাপচারের লাইভ ডেমো একটি ইউআরএল থেকে।

বেসিক বিকল্পসমূহ

নীচে পাওয়া কোড উদাহরণটি স্বয়ংক্রিয়ভাবে নির্দিষ্ট ওয়েবপৃষ্ঠায় আবিষ্কৃত প্রথম এইচটিএমএল টেবিলকে রূপান্তর করে 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 কে পাস করে রূপান্তর করতে পারে 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 পদ্ধতি, তবে এটি কেবল এক্সএলএসএক্স ফর্ম্যাট দিয়ে কাজ করবে। এই বিকল্পটি উত্পন্ন স্প্রেডশিট ওয়ার্কবুকের মধ্যে প্রতিটি টেবিলকে একটি নতুন শীটে রাখবে।

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

এইচটিএমএল টেবিলগুলি JSON এ রূপান্তর করুন

পার্ল এবং গ্র্যাজআইটি দিয়ে আপনি পাওয়া এইচটিএমএল টেবিলগুলিকে রূপান্তর করতে পারেন intও জেএসওএন। শুরু করতে নির্দিষ্ট উল্লেখ করুন json বিন্যাস প্যারামিটারে। উদাহরণস্বরূপ আমরা একটি তৈরি করছি সিঙ্ক্রোনাস কল ব্যবহার করে SaveTo পদ্ধতি, যা JSON ফিরিয়ে দিচ্ছে string, এটি তখন লাইব্রেরি দ্বারা পার্স করা যায় তাদেরকে JSON :: ব্যকরণগত.

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