我試圖獲取具有特定ID的src。 例子:獲取具有特定ID的src的網頁抓取
<img id="hi_1" src="url of image 1">
<img id="hi_2" src="url of image 2">
<img id="hi_3" src="url of image 3">
result = url of image 1;
我有這樣的代碼:
$html = file_get_contents('url of site');
preg_match('here I don't know what to do', $html, $src);
$src_out = $src[1];
可能的[你如何解析和處理PHP中的HTML/XML?]的重複(http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html- xml-in-php) –