0
我有一个使用curl-multi的脚本,它通过多个站点为内容剪贴。我想知道为每个网站输出特定内容的更快方式。使用curl_multi与preg_match_all输出网站,网站加载速度慢
<?php // Get the tables for 1 website
preg_match_all("/\<tbody\>(.*?)\<\/tbody\>/is",
$res[0], $matches);
foreach($matches[0] as $value)
{
echo $value;
}
// Get the tables for site 2
preg_match_all("/\<div class=\"dealsListS\"\>(.*?)\<\/div\>/is",
$res[1], $matches);
foreach($matches[0] as $value)
{
echo $value;
}
// Get the tables for site 3
preg_match_all("/\<div class=\"city_save\"\>(.*?)\<\/div\>/is",
$res[2], $matches);
foreach($matches[0] as $value)
{
echo $value;
}
// Get the tables for site 4
preg_match_all("/\<div class=\"offer-stream\"\>(.*?)\<\/div\>/is",
$res[3], $matches);
foreach($matches[0] as $value)
{
echo $value;
}
?>
需要帮助,使页面不会加载太久。这只是我需要添加更多内容的一小部分。
**不要使用正则表达式来解析HTML **,使用[HTML DOM解析器来代替(http://simplehtmldom.sourceforge.net/) – 2011-08-18 00:22:32