我按照php100-16节上说的方法调用了一个查询页面,页面抓进来了,我用的文件名是cha.php,http://localhost/cha.php对方的页面文件是http://www.xxx.com/ty.aspx他的post提交页面也是ty.aspx可是我这边查询提交是还是提示localhost/ty.aspx好像ty.aspx文件名没有被替换成cha.php这个文件,我怎么才能替换post的值直接在我的页面上显示查询结果?我如何才能忽略我所抓取的内容多余部分? 
我说是用的小偷程序是这样的:
<?php
$url = "http://www.xxx.com/ty.aspx";
$fp = @fopen($url, "r") or die("超时!");
$fcontents = file_get_contents($url);
eregi("<form name=\"form2\" method=\"post\" action=\"ty.aspx\" id=\"form2\">(.*)</form>", $fcontents, $aa);
$aa=str_replace("src=\"code.aspx","src=\"http://www.xxx.com/code.aspx",$aa);  // 这里替换了程序中的验证码地址$y=str_replace("src=\"cha.php","src=\"http://www.xxx.com/ty.aspx",$aa); // 在这里我想替换提交页面地址post页面地址这个写法对吗?echo $y;这里输出了结果可是提交查询时出现http://localhost/ty.aspx 无法查询?
?>
还有一个问题我如何才能忽"<form name=\"form2\" method=\"post\" action=\"ty.aspx\" id=\"form2\">(.*)</form>",这部分多余的一些内容,如何才能 实现调用内容的文字替换? 请高手指点,要是能详细举个例子就更好了。 谢谢!.

解决方案 »

  1.   

    ?
    src是不是action
    忽略"<form name=\"form2\" method=\"post\" action=\"ty.aspx\" id=\"form2\">(.*)</form>"你还怎么提交
      

  2.   

    对把action返回值要替换成我当前用的http://localhost/cha.php这个页面,不知如何实现?
    还有一个问题我如何才能忽"<form name=\"form2\" method=\"post\" action=\"ty.aspx\" id=\"form2\">(.*)</form>",这部分多余的一些内容,比如一些广告文字连接等等
    或者如何才能 实现调用内容的文字替换?
      

  3.   

    例如:可以根据需要通过指定标记来剥离替换一些不必要的东西 /**
         * 清除javascript标记 
         * 
         * @param string $document document
         * 
         * @return string
         * 
         */
        function clearJsTag ($document)
        {
            $document = trim($document);
            if (strlen($document) <= 0) {
                return $document;
            }
            
            $search = array(
                "'<script[^>]*?>.*?</script>'si",  // 去掉 javascript 
            );
            
            $replace = array(
                "", 
            );
            
            return @preg_replace($search, $replace, $document);
        }
      

  4.   

    提交查询时页面转移到ty.aspx这个页面为什么不在我的页面上显示结果啊比如 在这个页面上显示结果http://localhost/cha.php