1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <form name ="friendReverse" method ="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 無名ID<input type="text" size="20" name="id" value="<?php echo $_POST['id'];?>"/> <input type="submit" size="10" value ="好友叫我啥"/> </form> <?php if(isset($_POST['id'])){ $content = getHtml('http://www.wretch.cc/friend/'.$_POST['id'].'&c=1'); $count = preg_match_all( "!ddtip\("(.*?)","(.*?)","Default group"!is", $content, $matches ); echo "<table>"; for($i=0; $i<$count; $i++){ if($matches[2][$i]!="") echo "<tr><td>".$matches[1][$i]."</td><td>叫你</td><td>".json_decode('"'.$matches[2][$i].'"').'</td></tr>'; } echo '</table>'; } function getHtml($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "$url"); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); $result = curl_exec($ch); curl_close($ch); return htmlspecialchars($result); } ?> |
Direct link: https://paste.plurk.com/show/255492