Website scrapping tool using wordpress custom plugin part 6 ( update operation )

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.

<a href='admin.php?page=edit-website&id=<?php echo $print->id; ?>'>
<button class='btn btn-success btn-sm' type='button'>Edit</button></a>
edit-website

<?php

if(isset($_POST['update'])){

global $wpdb;

$website_url = $_POST['website_url']; 
$heading_selector = $_POST['heading_selector'];
$thumb_selector = $_POST['thumb_selector'];
$detail_url_selector = $_POST['detail_url_selector'];
$id = $_POST['id'];

$q = $wpdb->query("UPDATE wp_websites SET website_url='$website_url',
heading_selector='$heading_selector', thumb_selector='$thumb_selector', details_page_url='$detail_url_selector' WHERE id=$id");

echo "<script>location.replace('admin.php?page=edit-website&id=$id');</script>";

}

?>


<?php

global $wpdb;
$id = $_GET['id'];
$result = $wpdb->get_results("SELECT * FROM wp_websites WHERE id = $id");
foreach ($result as $key => $print) {

$website_url = $print->website_url;
$heading_selector = $print->heading_selector;
$thumb_selector = $print->thumb_selector;
$details_page_url = $print->details_page_url;

}

?>

<div class="card">

<h2 style="text-align:center;"><u>Edit Website</u></h2>
<form action="admin.php?page=edit-website" method="post">
<div class="form-group">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<label for="website_url">Website url:</label>
<input type="text" class="form-control" name="website_url" value="<?php echo $website_url; ?>">
</div>

<div class="form-group">
<label for="selector">Heading Title Selector:</label>
<input type="text" class="form-control" name="heading_selector" value="<?php echo $heading_selector; ?>">
</div>

<div class="form-group">
<label for="thumb">Thumbnail Selector:</label>
<input type="text" class="form-control" name="thumb_selector" value="<?php echo $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" value="<?php echo $details_page_url; ?>">
</div>

<button type="submit" class="btn btn-default" name="update">Update</button>
</form>

</div>

 

 

 

Leave a Reply