我一直试图找出如何在php中使用snoopy类。我尝试使用snoopy从谷歌搜索任何内容。我发现谷歌搜索的形式是name = q和action = / search
如何将我的史努比代码设置为正确的代码。
$s=new Snoopy();
$form=array("q"=>"spiderman");
$s->httpmethod = "GET";
$s->submit("http://www.google.com",$form);
echo $s->results;
我得到了405结果。
答案 0 :(得分:1)
<?php
// include snoopy library
require('Snoopy.class.php');
// initialize snoopy object
$snoopy = new Snoopy;
$url = "http://t.qq.com";
// read webpage content
$snoopy->fetch($url);
// save it to $lines_string
$lines_string = $snoopy->results;
//output, you can also save it locally on the server
echo $lines_string;
?>