code4craft / code4craft/xsoup

使用Xpath的contains函数出现问题

Open
#40 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
474
Forks
148
PR merge metrics
No merged PRs in 30d

Description

举例:https://club.autohome.com.cn/bbs/thread/86f2870bac840396/72293736-1.html
在浏览器审查元素-Console中输入
$x("//div[@class='conleft fl']/ul[@class='leftlist']/li[contains(text(),'帖子')]/a[1]/text()")
得到(7) [text, text, text, text, text, text, text]
而使用Webmagic集成的Xsoup
page.getHtml().xpath("//div[@class='conleft fl']/ul[@class='leftlist']/li[contains(text(),'帖子')]/a[1]/text()").all();
会得到一个空集合,求解

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the XPath expression against the linked Autohome page in the browser console and through WebMagic's Xsoup call. Trace how Xsoup handles contains(text(),'帖子') and compare the selected nodes; done means the Xsoup query returns the expected text nodes or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.