autoname
V2EX  ›  Java

jsoup 取值问题

  •  
  •   autoname · Jun 25, 2020 · 2221 views
    This topic created in 2147 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
        1
    itechify  
    PRO
       Jun 25, 2020 via Android
    搜了一下,jquery 的 ID 匹配可能是这样:

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

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

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