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 6f4d6ee commit 40bf1f7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scraper.php
Expand Up @@ -10,7 +10,7 @@
// creating sqlite database
try {
$db->query('CREATE TABLE data(
sno int(100),
sno int(10),
title VARCHAR(100),
price int(10),
PRIMARY KEY (sno))');
Expand All @@ -32,14 +32,14 @@
//To count the collected data
if($r[$i] || $m[$i] !=""){ $count++;}

$serial = $i;
echo "Sno: " . $serial . "\n";
$sno = $i;
echo "Sno: " . $sno . "\n";
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' => $serial , 'title' => strip_tags($r[$i]) , 'price' => $no_ws));
$articles = array(array('sno' => $sno , '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();
Expand Down

0 comments on commit 40bf1f7

Please sign in to comment.