-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdescription_trimming.php
41 lines (29 loc) · 1.13 KB
/
description_trimming.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
ini_set('max_execution_time', '2400');
set_time_limit(2400);
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "scraping";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
for($i=1;$i<=5871;$i++){
$sql = "SELECT `body` FROM `products` WHERE `id` = ".$i;
$result = mysqli_query($conn, $sql);
$data = mysqli_fetch_array($result, MYSQLI_ASSOC);
if(!empty($data['body']))
{
$a = str_replace(" ","",$data['body']);
$a = str_replace(" ","",$a);
$a = str_replace("<small>","<h3>",$a);
$a = str_replace("</small>","</h3>",$a);
$a = str_replace("Key Features","<h3>Key Features</h3>",$a);
$a = str_replace("Information & Materials","<h3>Information & Materials</h3>",$a);
$sql = "UPDATE `products` SET `body`='".$a."' WHERE `id` = ".$i;
$result = mysqli_query($conn, $sql);
}
}
mysqli_close($conn);
?>