Регулярка

Статус
В этой теме нельзя размещать новые ответы.
Что на последние то??
Я же выложил, что не так?
PHP:
<? 
$result = <<<HERO 
<a href="javascript:launchArticleSlideshow();"><img 
src="/resources/r/?m=02&d=20100322&t=2&i=79830200&w=155&r=2010-03-22T081236Z_01_AMUE62L0MT100_RTROPTP_0_ORUTP-USA-HEALTHCARE" 
border="0" alt="Photo" 
/> 
HERO; 
preg_match('#(?<=src\=\").*(?=\")#',$result,$key); 
for ($i=0;$i<count($key);$i++){ 
  echo $key[$i]; 
  }  
?>
Научись в PHP разбираться, а не постить просто так.
 
Я не пойму чего у вас там не парситься, да извиняюсь чуток накосячил с кодом, извините писал в 4 часу утра пост, естнственно не проверял.

Собственно поправленный рабочий код (проверил лично:(
PHP:
$IN = '<a href="javascript:launchArticleSlideshow();"><img src="/resources/r/?m=02&d=20100322&t=2&i=79830200&w=155&r=2010-03-22T081236Z_01_AMUE62L0MT100_RTROPTP_0_ORUTP-USA-HEALTHCARE" border="0" alt="Photo"';

preg_match('#<img src="(.+)" border="0" alt="Photo"#', $IN, $OUT);
print_r($OUT[1]);

Как видно из кода суть не изменилась. От себя могу добавить народ вы мозг то временами включайте, а не тупо копи пастом занимайтесь.
 
Ребята, чего Вы ругаетесь?
Вот урл. Пробовал Ваши регулярки - не парсят они картинку.
 
Значит проблема в скрипте. Показывай весь скрипт
 
PHP:
<?

function full_url ($url,$host)
{
if ($url[0]=='/')
{$host_tmp=str_replace ("http://","",$host);
$ar=explode ("/",$host_tmp);
$fullurl='http://'.$ar[0].$url;}

elseif ($url[0]=='h'&&$url[4]==':'){
$fullurl=$url;

}

else 
{
$host_tmp=str_replace ("http://","",$host);
$ar=explode ("/",$host_tmp);
unset ($ar[count($ar)-1]);
$fullurl='http://'.implode ("/",$ar).'/'.$url;
}

return ($fullurl);

}
function uploading ($urlf){
$postdata = array( 'upload' => 'yes', 
'im'=>'7', 
'JQ'=>'85',  
'URLF' => trim($urlf), 
'j' => 'yes'); 

$agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)";
$ch = curl_init ("http://radikal.ru/action.aspx");
@curl_setopt ( $ch , CURLOPT_USERAGENT , $agent );
@curl_setopt ( $ch , CURLOPT_HTTPHEADER , false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
curl_setopt($ch, CURLOPT_TIMEOUT, 20); 
curl_setopt($ch,CURLOPT_ENCODING,"gzip,deflate");
curl_setopt($ch, CURLOPT_REFERER, "");


curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); 


$tmp = @curl_exec ( $ch );
curl_close ( $ch ); 


preg_match('|id="input_link_1" value="(.*?)"|is', $tmp, $out); 
$result = $out[1];  

return($result);
}


function parsing ($url2,$theme){


$html=file_get_contents ($url2);
preg_match ('|<span id="midArticle_start"></span>(.*?)<div>|is',$html,$preg);
$pos = strpos($text, "-");
$len=strlen($text);
$text = substr($text, $pos,$len-$pos);
preg_match ('|<h1>(.*?)</h1>|is',$html,$preg);
$title=strip_tags($preg[1]);
preg_match ('#<img src="(.+)" border="0" alt="Photo"#',$html,$preg);
var_dump($preg);
echo $html;
$imgurl=full_url($preg[1],'ru.reuters.com');
}
$db=mysql_connect ("localhost","root","");
mysql_select_db ("parser",$db);
mysql_query ("SET NAMES Utf8");
mysql_set_charset('utf8',$db); 
$html=file_get_contents ("http://ru.reuters.com/news/archive/topNews?date=03242010");
preg_match('|<a href="/article/(.*?)"|is',$html,$preg);
parsing ("http://ru.reuters.com/article/topNews/idRUMSE62N1LM20100324",'hot');

?>
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху