View Single Post
ישן 15-03-14, 16:15   # 14
dor77
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Jan 2008
הודעות: 1,650

dor77 לא מחובר  

טוב..הצלחתי..נראה לי יצא מאוד מסורבל..(אם תראה דרך לייעל, בכיף)..
מצרף את הקוד..
ותודה רבה לך.


PHP קוד:
function get_source_code($url)
{
  
$ch = curl_init();
  
$useragent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36";
  
  
curl_setopt($ch, CURLOPT_URL, $url);
  
curl_setopt($ch, CURLOPT_HEADER, 0);
  
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  
  
$source_code = curl_exec($ch);
  
  
curl_close($ch);
  
$source_code = str_replace(array("\r", "\n"), '', $source_code);

  return 
$source_code;
}

$s_c = get_source_code('http://www.bla.com');
$s_c = preg_replace('~>\s+<~m', '><', $s_c);

$start = '<div id="menu">
            <ul class="menu">
                <li>'
;
$end = '</li>';


$start = preg_replace('~>\s+<~m', '><', $start);
$end = preg_replace('~>\s+<~m', '><', $end);

preg_match('/'.preg_quote($start, '/').'(.*?)'.preg_quote($end, '/').'/is', $s_c, $match);
echo 
$match[1]; 
__________________
מתכנת php אמין ומקצועי.
מחירים נוחים!
יצירת קשר: 0544378743
  Reply With Quote