我正在尝试PHP
从网页中获取一些信息。我找到了一些使用建议htmlSQL
,可以很容易地从 HTML 中获得特定的价值。我已经阅读了它附带的所有示例,但是,我有一个非常简单的问题。当我执行我的脚本时,输出显示
PHP Fatal error: Class 'htmlsql' not found in /home/jeff/htmlsql2.php on line 5
我已经htmlsql.class.php
从网站上下载了文档并将其放在 HOME 中。谁能帮我解决这个问题?
以下是我的代码。在这种情况下,我想从网页中获取所有产品名称。
<?php
//using htmlSQL to scrap the web, reference url http://www.devquotes.com/2010/12/07/seo-scraping-with-websql/
include_once("htmlsql.class.php");
//create new htmlsql and link the web
$wsql = new htmlsql();
if (!$wsql->connect('url','http://m.dicksmith.com.au/#/Product/Search?query=IPOD')){
print 'Error while connecting:' . $wsql->error;
exit;
}
//limit range
$wsql->isolate_content('<div class="productItemInner">', '</div>');
//try to fetch
if(!$wsql->query('SELECT * FROM p WHERE $class=="blueFont largeFont"')){
print "Query error:".$wsql->error;
exit;
}
foreach($wsql->fetch_array() as $row){
print_r($row);
}
?>