postgraduatedegrees=tree.xpath('//*[@id="block-scholarly- content"]/div/article/div/div/div//*[contains(text(),"Degree of")]/text()') postgraduatedegreeslinks=tree.xpath('//*[@id="block-scholarly- content"]/div/article/div/div/div//*[contains(text(),"Degree of")]/@href') Output: len(postgraduatedegrees) Out[222]: 52 len(postgraduatedegreeslinks) Out[223]: 40
I have tried using string(.) and textContant()
postgraduatedegreeslinks=tree.xpath('//*[@id="block-scholarly- content"]/div/article/div/div/div//*[contains(text(),"Degree of")][@href]/text()') for p in postgraduatedegreeslinks print (p.extract)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)