שלום.
אני מתחבר לאתר כלשהו באמצעות curl, שואב את קוד המקור שלו ורוצה לקחת את כל התוכן שיש בין 2 תגיות html..חשוב לציין שכל פעם התגיות יכולות להשתנות לכן אני חייב שזה יהיה דימני.
בהוצאת מילה בין שתי מילים אין בעיה..אבל כשמערבים תגיות של html זה נותן שגיאה.
PHP קוד:
Undefined offset: 1 in D:wampwwwcurl.php on line 29
זו שורה 29:
הנה הקוד:
PHP קוד:
function get_source_code($url)
{
$ch = curl_init();
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1)".
" Gecko/20061204 Firefox/2.0.0.1";
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 = nl2br(htmlspecialchars($source_code));
}
$s_c = get_source_code('http://www.blabla.com');
$start = '<div id="login">';
$end = '<div id="search">';
preg_match('/'.preg_quote($start).'(.*?)'.preg_quote($end).'/is', $s_c, $match);
echo $match[1];
אשמח לעזרה, תודה.