douri4459 2013-12-31 13:39
浏览 18

如何使用PHPCrawl从站点检索特定数据

I am using the PHPCrawl for a website I would like to receive the data from, but I do not know where to start with retrieving data from (eg) a span with a specific class.

per example I would like to retrieve the name "Jan" from this span:

 <span class="firstname">Jan</span>

I have tried using DOMDocument() and DOMXPath() but I get errors when the loading the html string.

So here is what I had so far:

 $doc = new DOMDocument();
 $doc->loadHTML($PageInfo->content);
 $xpath = new DOMXPath($doc);

 foreach ($xpath->query("//span[@class='family-name']") as $node) {
     echo "Family name: " . $node . "
";
 }

However using this will give errors like these:

PHP Notice:  DOMDocument::loadHTML(): Namespace prefix g is not defined in Entity, line: 294 in /var/www/crawl/www/crawl.php on line 30
PHP Warning:  DOMDocument::loadHTML(): Tag g:plusone invalid in Entity, line: 294 in /var/www/crawl/www/crawl.php on line 30

Since I cannot change the html code (this is extracted by PHPCrawl) I need to do something else. However I don't know what. Does PHPCrawl itself has any tools for doing so?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 多址通信方式的抗噪声性能和系统容量对比
    • ¥15 winform的chart曲线生成时有凸起
    • ¥15 msix packaging tool打包问题
    • ¥15 finalshell节点的搭建代码和那个端口代码教程
    • ¥15 Centos / PETSc / PETGEM
    • ¥15 centos7.9 IPv6端口telnet和端口监控问题
    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 海浪数据 南海地区海况数据,波浪数据
    • ¥20 软件测试决策法疑问求解答