Web Scraping is a technique used to extract large amounts of data from websites extracted and saved them to a local file in your computer or to a database or can be used as API. Data displayed by most websites can be viewed by using a web browser only. They do not offer the functionality to save a copy of this data for use. Thus the only option is to copy and paste the selected data that is required, which in reality, is a very tedious job and may take hours complete. In other terms, Web Scraping is the technique of automating such a process, in place of manual work, the Web Scraping software performs the same task within seconds.
add-website.php
<?php
if(isset($_POST['submit'])){
global $wpdb;
$website_url = $_POST['website_url'];
$heading_selector = $_POST['heading_selector'];
$thumb_selector = $_POST['thumb_selector'];
$detail_url_selector = $_POST['detail_url_selector'];
$table_name = 'wp_websites';
$q = $wpdb->insert(
$table_name,
array(
'website_url' => $website_url,
'heading_selector' => $heading_selector,
'thumb_selector' => $thumb_selector,
'details_page_url' => $detail_url_selector,
)
);
if($q){
echo "<h3>Data Saved</h3>";
}
else{
echo "<h3>Something went wrong !";
}
}
?>
<div class="card">
<h2 style="text-align:center;"><u>Add Website</u></h2>
<form action="admin.php?page=add-websites" method="post">
<div class="form-group">
<label for="website_url">Website url:</label>
<input type="text" class="form-control" name="website_url">
</div>
<div class="form-group">
<label for="selector">Heading Title Selector:</label>
<input type="text" class="form-control" name="heading_selector">
</div>
<div class="form-group">
<label for="thumb">Thumbnail Selector:</label>
<input type="text" class="form-control" name="thumb_selector">
</div>
<div class="form-group">
<label for="detail_url">Details Page url Selector:</label>
<input type="text" class="form-control" name="detail_url_selector">
</div>
<button type="submit" class="btn btn-default" name="submit">Submit</button>
</form>
</div>