
DeepSeek 🤖
Members-
Posts
17 -
Joined
-
Last visited
Profile Information
-
Gender
Not Telling
DeepSeek 🤖's Achievements

Newbie (1/5)
0
Reputation
-
So, I have the following pages downloaded from another server: http://zaqvka.in/kids/products/0052 http://zaqvka.in/kids/products/0053 ... http://zaqvka.in/kids/products/9969 To view them correctly I created simple Javascript append function in this page: http://zaqvka.in/kids/index.php?id=0052 (0052 can be changed with the ID of the product) I need the following things to be crawled from 0052 (for example): > name (потник) > size (68,74,80,86,92,98) > price (10) > image (http://carnivalkids.com/upl/products/52-1.jpg to be saved as 0052.jpg) I think everything could be done with cURL and preg_match, but I have the following problem: When I use cURL of [url="http://zaqvka.in/kids/index.php?id=0052"]http://zaqvka.in/kid...dex.php?id=0052[/url] I receive the data from the index.php (the Javascript function) and not from the final code... Does anyone knows how it can be done?
-
I made it with this way: .htaccess Rules: RewriteRule ^category/([^/]+)/([^/]+) /category.php?collection=$1 [NC] RewriteRule ^browse/([^/]+)/([^/]+) /browse.php?collection=$1 [NC] RewriteRule ^model/([^/]+) /model.php [NC] Recognizing: MODEL: $product = current(explode('.', end(explode('_', $_SERVER['REQUEST_URI'])))); CATEGORY: $category = current(explode('.', end(explode('_', $_SERVER['REQUEST_URI'])))); $collection = htmlspecialchars($_GET["collection"], ENT_QUOTES); BROWSE: $browse = current(explode('.', end(explode('_', $_SERVER['REQUEST_URI'])))); $collection = htmlspecialchars($_GET["collection"], ENT_QUOTES); Functions: function friendlyURL($string) { $string = preg_replace("`\[.*\]`U", "", $string); $string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i', '-', $string); $string = htmlspecialchars($string, ENT_COMPAT, 'utf-8'); $string = preg_replace("`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i", "\\1", $string); $string = preg_replace(array("`[^a-z0-9]`i", "`[-]+`"), "-", $string); return strtolower(trim($string, '-')); } Usage: echo <a href="<?=friendlyURL($product_name);?>">$product_name</a> Is it okay? :-)
-
Yep, I guess the basic problem would be the url generation and detection, right? Last night I was thinking about something like that.. URL Generation: function friendlyURL($string) { $string = preg_replace("`\[.*\]`U", "", $string); $string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i', '-', $string); $string = htmlspecialchars($string, ENT_COMPAT, 'utf-8'); $string = preg_replace("`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i", "\\1", $string); $string = preg_replace(array("`[^a-z0-9]`i", "`[-]+`"), "-", $string); return strtolower(trim($string, '-')); } URL Detection for PRODUCT: $url = $_SERVER['REQUEST_URI']; $last_uri = end(explode('_', $url)); $productid = current(explode('.', $last_uri)); .htaccess Rules: RewriteRule ^([^/]+) /model.php?id=$1 [NC] When I come back home I'll think about it
-
I want to make the links to my pages to looks from this: 1. CATEGORIES - http://daytona.bg/category?id=2&collection=04-2012 // opens category.php and tell to show all categories from collection 04-2012 with parentcat (parent category) - 2 2. PRODUCTS - http://daytona.bg/browse?id=22&collection=04-2012 // opens browse.php and tell to show all products from collection 04-2012 with category - 22 3. PRODUCT - http://daytona.bg/model?id=1286 // opens model.php and tell to show the product with ID 1286 To something like that: 1. CATEGORIES - http://daytona.bg/for-him/04-2012 2. PRODUCTS - http://daytona.bg/men-shirts/04-2012 3. PRODUCT - http://daytona.bg/men-lastic-shirt-silk-ysl-1286 Do someone have some suggestions how it can be done? EDIT: At the moment I have this in my .htaccess: ### OPTIONS ### Options +FollowSymLinks -Indexes -MultiViews AddDefaultCharset UTF-8 ### RENGINE ### RewriteEngine On RewriteBase / ### CONDITIONS ### RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ### ERROR DOCS ### ErrorDocument 404 /404 ### REWRITES ### RewriteRule ^([^\.]+)$ /$1.php [NC,L]
-
Nevermind, I did it. So now the question is: what is the best way to save it in the database?
-
Thanks! Now when I type print_r($cart) I get: Array ( [1] => Array ( => XXXL [qty] => 5 ) ) Now how can I use the foreach function to see the contents as: ID: 1, Size: XXXL, Quantity: 5 (for example)?
-
I'm starting to think that this is not possible :'( I tried to save the contents like: 1:XXXL, 2:S, 3:M for example but then I can't split it with explode() correctly..
-
Hi! I use the following PHP Session Shopping Cart (it's ready to use) <? session_start(); function showCart() { $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } foreach ($contents as $id=>$qty) { $output[] = 'You have '.$qty.' items with ID: '.$id; } } else { $output[] = 'You don\'t have items in your cart'; } return join('',$output); } if(isset($_SESSION['cart'])) { $cart = $_SESSION['cart']; } else { $cart = 0; } if(isset($_GET['action'])) { $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; case 'update': if ($cart) { $newcart = ''; foreach ($_POST as $key=>$value) { if (stristr($key,'qty')) { $id = str_replace('qty','',$key); $items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } for ($i=1;$i<=$value;$i++) { if ($newcart != '') { $newcart .= ','.$id; } else { $newcart = $id; } } } } } $cart = $newcart; break; } } $_SESSION['cart'] = $cart; echo showCart(); echo '<br/>'; echo '<a href="?action=add&id=1">Add to Cart</a>'; ?> Example of usage: === <a href="cart.php?action=add&id=1">Add to Cart</a> // Adding a new product in the cart with ID 1 <a href="cart.php?action=delete&id=1">Delete from Cart</a> // Deleting a new product in the cart with ID 1 <a href="cart.php?action=update&id=1&qty=5">Update Quantity to 5</a> // Updating the quantity of product with ID 1 === Everything is fine, but now I want to add sizes, something like: cart.php?action=add&id=1&size=XXXL. For example, the case "add" can be done like that: $cart = $_GET['id'].":".$_GET['size']; .. and then the products will be saved like 1:XXXL, but then the updating and deleting will not work .. Please help me, I'm very confused how this can be done
-
Nevermind, I did it with: $torrentid = 1; foreach($torrent->content() as $filename => $size) { $sqldb->query("INSERT INTO files (torrent, filename, size) VALUES('{$torrentid}','{$filename}','{$size}')"); }
-
This: echo "<pre>"; print_r($torrent->content()); echo "</pre>"; Returns: Array ( [Eureka.S05E01.HDTV.XviD-ASAP\Eureka.S05E01.HDTV.XviD-ASAP.avi] => 367011826 [Eureka.S05E01.HDTV.XviD-ASAP\eureka.s05e01.hdtv.xvid-asap.nfo] => 4798 [Eureka.S05E01.HDTV.XviD-ASAP\Sample\eureka.s05e01.hdtv.xvid-asap.sample.avi] => 7883092 ) Needs to be inserted to MySQL like: In other words, the array $torrent->content() needs to be inserted to MySQL as new lines at columns "filename" and "size". Please help me..
-
OMG!!! I just had to convert the .php file to ANSI! Now it's working!! Really thanks for the help, I'm very happy that it's working now! Thanks again
-
I'll check it now
-
Yep, it works that way, but when it opens the content page with the cURL it messes it up (I mean the cURL).. Here's my charset: Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3 Is it possible to be the problem? How can I see the cURL results?
-
Hi, thanks alot for the help - it works now, but only if I put it in a new file. Here's what's going on if I use it on the crawler.. // ... the cURL codes (they're working) ... // Content of the Page $contents = curl_exec($crawler->curl); // Find the Title $pattern = "/<title>(.*?)<\/title>/s"; preg_match($pattern, $contents, $titlematches); echo $titlematches[1]."<br/>"; // Find the Category $pattern = "~Тип</td><td(?>[^>]+)>((?>[^<]+))</td>~"; preg_match($pattern, $contents, $categorymatches); echo $categorymatches[1]."<br/>"; The HTML page: ("Тип" means Category and "Филми" means Movies) <title>The Matrix</title> <!--Some Codes Here--!> <tr><td>Тип</td><td valign="top" align=left>Филми</td></tr> <!--Some Codes Here--!> The result: The Matrix Notice: Undefined offset: 1 in /var/www/spider.php on line 117 Very strange! It's showing the title but not the category.. I've tried to echo $categorymatches[0], $categorymatches[2], $categorymatches[3] without any luck.
-
So, in a few words, I want this: $str = "Category</td><td valign='top' align=left>MOVIES</td>"; $pattern = "/Category<td(?>[^>]+)>((?>[^<]+))<\/td>/s"; preg_match($pattern,$str,$ms); print_r($ms); To returns: Array ( [0] => MOVIES [1] => MOVIES ) But it returns: Array ( )