您好我正在尝试使用下面给出的html抓取数据我通过以下方式获得了整个HTML
Elements b= doc.getElementsByClass("a");
然后,为了从tr标签中获取值,我使用了
Elements tr = b.getElementsByTag("tr");
但它显示错误为T 方法getElementsByTag(String)未定义类型Elements
我想获取tr标签的值请帮助我。我正在工作的html如下,
<table class="a">
<thead>
<tr>
<td>the<br>boy</td>
<td>ran<br>well</td>
<td>the<br>boy</td>
<td>ran<br>well</td>
</tr>
</thead>
<tbody>
<tr>
<td>6</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
答案 0 :(得分:1)
目前尚不清楚我们在谈论什么,java或javascript。
但是,不是首先使用className a
获取元素,然后迭代结果以获取标记为tr
的元素,而不是使用标记<tr/>
获取var tr = document.querySelectorAll(".a tr");
的元素。单一陈述。
在javascript中,该方法为querySelectorAll
:
Elements tr = doc.select(".a tr");
在jsoup中(我不熟悉java / jsoup,因此只是一个猜测)存在方法select
{{1}}
答案 1 :(得分:0)
使用类和标记名称获取html元素
使用以下代码。
select * from (
SELECT CAST(SurveyDept AS NVARCHAR(100)) as Dept_name,
CAST(SurveySubDept AS NVARCHAR(100)) as Subdept_name
AVG( SurveyReachability ) as total_R,
AVG( SurveyProfessionalism ) as total_P,
AVG( SurveyProactiveness ) as total_Pr,
AVG( SurveyCompetence ) as total_C,
AVG( SurveyResponse ) as total_Re
FROM dbo.tb_SurveyDeptInfo GROUP BY CAST(SurveyDept AS NVARCHAR(100)), CAST(SurveySubDept AS NVARCHAR(100))
ORDER BY CAST(SurveyDept AS NVARCHAR(100)),CAST( SurveySubDept AS NVARCHAR(100))
) tmp
WHERE tmp.Subdept_name NOT IN (
SELECT *
FROM dbo.tb_SurveyDeptInfo
WHERE
CAST(SurveySubDept AS NVARCHAR(100)) = 'Transfers'
OR
CAST(SurveySubDept AS NVARCHAR(100)) = 'Check & Utility Service Payments'
)
应该有效: - )