dongpangfu6322 2011-03-31 12:40
浏览 16
已采纳

从PHP中的另一个站点的页面中提取内容的最小脚本

Very simple thing. I sometimes want to access urban dictionary but it is blocked where I am. Given a form like

<form method="get" action="<?PHP echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<input type="text" name="what" value="" />
<input type="submit" />
</form>

what do I need to add to have it return the content of the entry from urban dictionary for value entered? For example using CURL or getFile or something as simple as possible

Update:

This works!

<form method="get" action="">
<input type="text" name="what" value="" />
<input type="submit" />
</form>

<?PHP
$what = isSet($_GET["what"])?htmlentities($_GET["what"]):"";
echo file_get_contents("http://www.urbandictionary.com/define.php?term=".urlencode($what));
?>
  • 写回答

3条回答 默认 最新

  • doubu2730 2011-03-31 12:47
    关注

    very simple, very weird file_get_contents($_POST['what']);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题