- PHP code
<?php //调用格式:localhost/getpro.php?userid=slowstang95/// $userid=$_GET["userid"]; $url="http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback2&userid=".$userid; $str=file_get_contents($url); $start='</span></a> <span class="mbg-l"> ( '; $end='<img src="http://q.ebaystatic'; $content=str_substr($str , $start, $end); echo $content; function str_substr($str ,$start, $end) { $x = strpos($str, $start); $y = strpos($str, $end); $getstr= substr($str,$x+strlen($start),$y-$x); $getstr2=str_replace('<img src="http://q.ebaystatic.com/a',"",$getstr); //!!! return $getstr2; } ?>
------解决方案--------------------
- PHP code
$userid=$_GET["userid"]; $url="http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback2&userid=".$userid; $str=file_get_contents($url); $pattern='/<span class="mbg-l">\s*\((.*?)<img src="http:\/\/q\.ebaystatic\.com\/a/'; preg_match($pattern,$str,$match); print_r($match[1]);