使用 jsoup 解析表时出现问题
我已经坚持这个问题好几天了。我正在尝试创建一个用于论坛 Fightlockdown(它是一个 MMA 论坛)的应用程序。
我遇到麻烦的区域是 http://fightlockdown.com/ 等页面forum/forumdisplay.php?f=1 我想将表格中的每个部分显示为一行,但无法仅抓取这些部分,即 UFC、终极战士等...
我最接近的能够得到就是抢夺所有的锚标记,但页面上显然还有其他标记,如果我不正确地将它们从返回的元素中删除,它们可能会导致我的结果丢失。
我无法弄清楚如何让表格缩小我的结果范围,因为据我所知 doc.select("table.tborder") 不会产生任何结果,doc.select("td. alt1 活动”)。
任何帮助将非常感激。提前致谢。
I have been stuck on this for a few days now. I am attempting to create an app that is for the forum fightlockdown (its an MMA forum).
The area where I am running into trouble is on pages such as http://fightlockdown.com/forum/forumdisplay.php?f=1 where I would like to display each section in a table as a row but am having trouble grabbing only the sections i.e. UFC, The Ultimate Fighter, etc...
The closest I have been able to get is grabbing all of the anchor tags but there are obviously others on the page which could throw off my results if I don't remove them from the returned Elements correctly.
I have not been able to figure out how to get the table to narrow down my results since as far as I can tell doc.select("table.tborder") does not yield any results and neither does doc.select("td.alt1Active").
Any help would be very much appreciated. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您对要寻找的内容不是很具体,所以我会抛出一些代码,看看它是否是您要寻找的内容。
具体来说,在此页面上,您尝试拉取的 div 具有与其关联的两个类之一。此代码选择这些 div 并迭代它们,然后打印出 div 中的锚标记。
如果您需要更多帮助,请告诉我。
You are not very specific in what you are looking for, so I'll throw some code out there and see if it's what you are looking for.
On this page specifically, the divs you are trying to pull have one of two classes associated with them. This code selects those divs and iterates over them and then prints out the anchor tags in the divs.
Let me know if you need any more help.