2013-02-25 21 views
1

你好我解析網站(SHOP)這個腳本:環路,捲曲視爲一個連接

<?php 
date_default_timezone_set('Europe/Warsaw'); 
ini_set('memory_limit', '-1'); 
set_time_limit(120); 
require_once '../../../simple_html_dom.php';  
require_once'../../../functions.php'; 
echo '<meta http-equiv="content-type" content="text/html; charset=UTF-8">'; 
echo "Beginning import at: ".date('H').":".date('i')."\n"; 
mysql_connect ("localhost","xxxx","xxxx"); 
mysql_select_db ("sklepy"); 
mysql_query('SET CHARSET utf8'); 
$sklepy=(mysql_query("SELECT * FROM `ps_supplier` where id_supplier = 3")); 
do { 
$curl = curl_init(); 
$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'; 
$timeout = 5; 
$cookie = tempnam ("/tmp", "CURLCOOKIE"); 
curl_setopt($curl, CURLOPT_FAILONERROR, true); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($curl, CURLOPT_AUTOREFERER, true); 
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); 
curl_setopt($curl, CURLOPT_USERAGENT, $userAgent); 
curl_setopt($curl, CURLOPT_URL, $adres); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout); 
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie); 
$str = curl_exec($curl); 
curl_close($curl); 
/code for extracting data from DOM 
} 

while ($limit != $sklep['limit']); 

} 
?> 

,我有問題,即那些{}的每個循環被視爲新的連接解析服務器,~5分鐘後​​顯示有1000人在線, 如何更改代碼模擬一個長連接? PS。對不起,我的英文不好:)

回答