我一直在努力为搜索引擎优化目的编写自己的关键字排名扫描器。我找到了一个看起来非常有用的PHP类,但我无法弄清楚如何让它工作。
我对使用PHP的类/函数相当新。
这是我找到的代码: http://www.andreyvoev.com/programming/simple-serp-tracker-php-class/
我已经完全复制并粘贴了它,但它仍然无效。有人愿意向我解释一下吗?
修改
我最终做的是将整个事情放在一个脚本中,我在脚本的开头和类GoogleTracker一起使用了类,然后我就可以运行它了。
$test = new GoogleTracker(array ('lsp'), 'adventuretime.wikia.com', 50);
//$test->use_proxy('proxy.txt');
$test->run();
$results = $test->get_results();
// $debug = $test->get_debug_info();
print $results;
//print_r($debug);
当我在浏览器中运行它时,唯一打印的是
Array()
我做错了什么还是脚本?
答案 0 :(得分:1)
我不知道为什么我这么久才看到这个......是的,你做错了什么。您正在尝试将数组转换为字符串。
这不适用于普通的print()
函数,因为它期望字符串作为输入..而不是混合变量。要查看结果,您要么print_r()
,要么直接查看数组键:
$results = $test->get_results();
print($results["lsp"]);
答案 1 :(得分:0)
您必须在代码中包含此类:
include('serp_tracker.php');
// include the class GoogleTracker extends , the second class of bottom
$test = new GoogleTracker(array('git'), 'www.kernel.org', 50);
//$test->use_proxy('proxy.txt');
$test->run();
print_r($test->get_results());
echo "================<br>";
print_r($test->get_debug_info());