Skip to content

Commit

Permalink
Update scraper.php
Browse files Browse the repository at this point in the history
  • Loading branch information
OmairXcluesiv committed Feb 6, 2017
1 parent 8eacd54 commit b5b0794
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scraper.php
Expand Up @@ -32,15 +32,17 @@
//To count the collected data
if($r[$i] || $m[$i] !=""){ $count++;}

$serial = $i;
echo "Sno: " . $serial;
echo "Product Title: " . strip_tags($r[$i]) . "\n";
$p_text = strip_tags($m[$i]); // replace all HTML tags with plain text
$no_ws = preg_replace('/\s+/', '', $p_text); // remove one or more than one whitespace from grabbed data
echo "Product Price:" . $no_ws . "\n\n\n\n\n";

$articles = array(array('sno' => "1", 'title' => strip_tags($r[$i]) , 'price' => $no_ws));
$articles = array(array('sno' => $serial , 'title' => strip_tags($r[$i]) , 'price' => $no_ws));

foreach ($articles as $article) {
$exists = $db->query("SELECT * FROM data WHERE sno = " . $db->quote($article->sno))->fetchObject();
$exists = $db->query("SELECT * FROM data WHERE sno = ". $db->quote($article->sno))->fetchObject();
if (!$exists) {
$sql = "INSERT INTO data(sno, title, price) VALUES(:sno, :title, :price)";
} else {
Expand Down

0 comments on commit b5b0794

Please sign in to comment.