grab.doc.select('//div[@class="companyInfo"][1]/text()').text_list() ['', '', '', u'China 200030', '', '', '']
[u'China 200030']
grab.doc.select('//div[@class="companyInfo"][1]/text()').text_list() ['', '', '', u'China 200030', '', '', '']
[u'China 200030']
>>> from grab.selector import Selector >>> from lxml.html import fromstring >>> html = "<p> </p><p>Batman</p><p> </p>" >>> Selector(fromstring(html)).select('//p/text()').text_list() ['', 'Batman', ''] >>> Selector(fromstring(html)).select('//p/text()[normalize-space(.) != ""]').text_list() ['Batman']