2
我有我使用Scrapy正在解析以下HTML之间的文本:Scrapy:获取两个标识符
<TD CLASS="dddefault">
<SPAN class="fieldlabeltext">Associated Term: </SPAN>Fall 2015 - Qatar
<BR>
<SPAN class="fieldlabeltext">Registration Dates: </SPAN>Apr 09, 2015 to Aug 27, 2015
<BR>
<SPAN class="fieldlabeltext">Levels: </SPAN>Graduate, Undergraduate
<BR>
</TD>
我想要得到的东西一样这是第一个SPAN和BR和之后的日期之间的期限第二个SPAN和BR之间。
我尝试这样做:
term = response.xpath('//td[@class="dddefault"]/span[@class="fieldlabeltext"][1]/following-sibling::text()').extract()
date = response.xpath('//td[@class="dddefault"]/span[@class="fieldlabeltext"][2]/following-sibling::text()').extract()
但是,这些给我下面的一切文字也是如此。
是否有任何方法可以在SPAN之后和BR之前获取文本?
谢谢。