2013-02-25 76 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。对不起,我的英文不好:)

回答