0

有人可以告诉我为什么这行不通吗?

我收到错误“preg_match_all(): Compilation failed: nothing to repeat at offset 203”

$html = file_get_contents('http://services.runescape.com/m=itemdb_rs/results.ws?query='.urlencode($term).'&price='.$pricerange.'&members='.$members);
$html = str_replace(array("\r","\n"), "", $html);
$regexp = '#<tr data-item-id="(.*?)"><td class="(.*?)"><img src="(.*?)" alt="(.*?)"><a href="(.*?)">(.*?)</a></td><td><img src="(.*?)" alt="(.*?)" title="(.*?)"></td><td class="(.*?)">(.*?)</td><td class="(.*?)">(.?*)</td></tr>#';
preg_match_all($regexp, $html, $matches);
print_r($matches);

将在 file_get_contents 中使用的示例 url

http://services.runescape.com/m=itemdb_rs/results.ws?query=gold%20bar&price=all&members=no

谢谢 :)

4

1 回答 1

1

我建议您的错误就在这里:

<td class="(.*?)">(.?*)</td></tr>#

替换为

<td class="(.*?)">(.*?)</td></tr>#
于 2012-08-23T14:06:42.107 回答