如何在php中使用snoopy类

如何在php中使用snoopy类,php,snoopy,Php,Snoopy,我一直在尝试了解如何在php中使用snoopy类。我正试图用史努比从谷歌搜索任何东西。我发现谷歌搜索的形式是name=q,而action=/search 如何将我的snoopy代码设置为正确的代码 $s=new Snoopy(); $form=array("q"=>"spiderman"); $s->httpmethod = "GET"; $s->submit("http://www.google.com",$form); echo $s->results; 我得到了4

我一直在尝试了解如何在php中使用snoopy类。我正试图用史努比从谷歌搜索任何东西。我发现谷歌搜索的形式是name=q,而action=/search

如何将我的snoopy代码设置为正确的代码

$s=new Snoopy();
$form=array("q"=>"spiderman");
$s->httpmethod = "GET";
$s->submit("http://www.google.com",$form);
echo $s->results;
我得到了405分。


<?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;
?>

这是一个非常糟糕的库。看看Guzzle吧~@Phil我认为它只支持post方法?呃,第一个例子显示了GETrequest@Phil. 哎呀。对不起,我的错。谢谢你。