I am currently facing a challenge in selecting and matching elements within an HTML document using CSS selectors in the Scrapy framework. My issue lies with extracting information from a specific field using the last-child selector.
Below is the snippet of HTML code:
<td class="Table-Standard-AwardName Table-Scholarship-AwardName">
<a id="ctl00_ContentPlaceHolder1_ScholarshipDataControl_grvScholarshipSearch_ctl02_hylScholarshipName" class="bold" href="/Scholarships/14123/Family-Bursary,-The">Family Bursary, The</a>
<br>
<span>Field of Study:</span>
EcologyEnvironmental Science
</td>
The text "EcologyEnvironmental Science" is what I am trying to match. However, when I attempt to use the last-child selector, the output only displays 'Field of Study':
In [3]: response.css('td.Table-Standard-AwardName.Table-Scholarship-AwardName > *:last-child::text').extract_first()
Out[3]: 'Field of Study:'
Despite experimenting with different methods like nth-last-child()
and combining sibling selectors, I have been unable to achieve the desired result. Any assistance would be greatly appreciated!