autoname
V2EX  ›  Java

jsoup 取值问题

  •  
  •   autoname · Jun 25, 2020 · 2638 views
    This topic created in 2339 days ago, the information mentioned may be changed or developed.

    jsoup 取值问题。

    https://cdn.jsdelivr.net/gh/post-get/static/77e7d7bc2d2546d1b1c778b53ba480d7.png

    想取 no 开头的 id 里面的 th > a 怎么取,各位老哥指点下 谢谢

    Elements tbody = doc.select("#normalthread_*");

    这样取不行呢

    4 replies  •  2020-07-03 16:19:16 +08:00
    itechify
    itechify
    Jun 25, 2020 via Android
    1
    搜了一下,jquery 的 ID 匹配可能是这样:

    匹配开头的元素:
    $("div[id^='aaa']")
    匹配结尾的元素:
    $("div[id$='aaa']")
    匹配包含的元素:
    $("div[id*='aaa']")

    https://blog.csdn.net/chenhuade85/article/details/7575827

    没测试过。jsoup 和 jquery,css 选择器用法差不多吧,希望生效
    siweipancc
    siweipancc
    Jun 25, 2020 via iPhone
    2
    chrome 元素右键,xpath
    ONCEsama
    ONCEsama
    Jun 28, 2020
    3
    doc.select("[id^=normalthread_]");
    可以这样写,匹配属性名为 id,属性值以 normalthread_开头的元素
    autoname
    autoname
    OP
    Jul 3, 2020
    4
    @ONCEsama 嗯是这样 取靠谱 感谢大佬回答
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   982 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 68ms · UTC 19:25 · PVG 03:25 · LAX 11:25 · JFK 14:25
    ♥ Do have faith in what you're doing.