首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xpath/PHP:匹配类子字符串的问题

Xpath/PHP:匹配类子字符串的问题
EN

Stack Overflow用户
提问于 2019-04-09 07:40:29
回答 1查看 72关注 0票数 0

我试图在p元素的class属性中匹配一个简单的子字符串,但得到了错误:

代码语言:javascript
复制
$pElements = $crawler2
  ->filter(
 "p[contains(@class, 'price')]"); 
  // Expected operator, but <delimiter "(" at 10> found

  // "descendant-or-self::p[contains(@class, 'price')"); 
  // Unexpected pseudo-element "::p" found not at the end of a selector

我从这里得到的第二个(注释)选择语句的前缀是:https://symfony.com/doc/current/components/css_selector.html

我在PHP中使用这个库和Goute进行web抓取。

从错误(在服务器错误日志中)看起来xpath是坏的。有没有人能看出其中的错误?

EN

回答 1

Stack Overflow用户

发布于 2019-04-09 07:50:56

首先,你没有结束的]括号

尝试此字符串:在filter函数中使用"p[contains(@class, 'price')]"

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55583231

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档