现有如下表单,用POST提交到远程服务器后:<form action="http://tool.httpcn.com/zi/so.asp" method="post" target="_blank">
<input type="text" name="wd" value="赵">
<input type="hidden" name="Tid" value="1">
<input type="submit" value="Submit">
</form>用POST提交后发生如下跳转:
http://tool.httpcn.com/Html/Zi/37/KOTBPWCQKOXVDMEUY.shtml
请问本地服务器PHP有办法捕捉到这个跳转后的页面吗?
因为要提取里面的汉字解释.
<input type="text" name="wd" value="赵">
<input type="hidden" name="Tid" value="1">
<input type="submit" value="Submit">
</form>用POST提交后发生如下跳转:
http://tool.httpcn.com/Html/Zi/37/KOTBPWCQKOXVDMEUY.shtml
请问本地服务器PHP有办法捕捉到这个跳转后的页面吗?
因为要提取里面的汉字解释.
很简单就300多行代码.因为简单, 带来的好处是轻量级, 可以随意修改...坏处就是功能很简易...不过对于你的需求, 在你自己的php服务端通过它做一次转发(可以做缓存), 然后给这个客户端加上redirect处理, 就可以了.
你那边file_get_contents可以打开这个站点吗?
http://tool.httpcn.com/zi/so.asp?wd=赵&Tid=1
我刚试了, 我这里打不开...我用fopen能读baidu.com的东西
可以也读不了这个站..求解释.!!
http://tool.httpcn.com/zi/so.asp?wd=赵&Tid=1
是GET方式提交,打不开的.
提交之后就跳转了,形式诸如:
http://tool.httpcn.com/Html/Zi/30/PWRNUYMERNMEKOXVB.shtml (王)
http://tool.httpcn.com/Html/Zi/37/KOTBPWCQKOXVDMEUY.shtml (赵)
就是想捕捉到这样的页面,以便缓存到本地,但一直找不到办法.
file_put_contents('filename', $content);
print_r()下,里面的url就是你需要的http://tool.httpcn.com/Html/Zi/37/KOTBPWCQKOXVDMEUY.shtml
使用curl的时候记得加上
curl_setopt($ch, CURL_FOLLOWLOCATION, 1);
发现http://tool.httpcn.com/Zi/So.asp?tid=1&wd=可以直接在PHP里面用,<?php
$word=$_GET?$_GET['wd']?$_GET['wd']:'赵':'李';
function page($word){return 'http://tool.httpcn.com/Zi/So.asp?tid=1&wd='.$word;}
echo page($word);
?>
<form action="">
<input type="text" name="wd" value="<?php echo $word ?>">
<input type="hidden" name="Tid" value="1">
<input type="submit" value="查字">
<a href="?wd=<?php echo $word ?>"><?php echo $word ?></a>(localhost)
</form>
<?php
$cache=file_get_contents(page($word));
file_put_contents('cache.txt',$cache);
echo $cache;
?>不过在查"赵钱孙李周吴郑王"时还是有"李"和"吴"会查不到数据,
可是在远程上查询是有数据的,为什么?
赵(localhost)
首页 > 新华字典 > 赵
基本解释 详细解释 汉语字典 康熙字典 说文解字 相关查询『赵』 繁体字:趙
拼音:zhào 注音:ㄓㄠˋ
部首:走 部首笔画:7 总笔画:9
康熙字典笔画( 趙:14; )五笔86:FHQI 五笔98:FHRI 仓颉:GOK
四角号码:44800 UniCode:U+8D75 规范汉字编号:1378=======================================================http://tool.httpcn.com/Zi/So.asp?tid=1&wd=李
李(localhost)
首页 > 新华字典 > 查字(_)
汉字查询:请直接输入汉字进行查询。
◎ 很抱歉,您查询的结果不存在!
我试了下,提示出错,后来发现前缀应该是"CURLOPT_",
这个扩展确实不错!"李","吴"也能查到数据了.