2016-05-11 123 views
0

我要在以下链接http://gepris.dfg.de/gepris/projekt/268853字符串迈克尔博士教授Eiermann类别beteiliger Wissenschaftler提取。 Xpath查询必须如何正确。从输出我得到的字符串Fachliche ZuordnungXpath查询与scrapy

代码段使用XPath查询:

start_urls =['http://gepris.dfg.de/gepris/projekt/268853',] 
def parse(self, response): 
    for sel in response.xpath("//*[contains(@class,'content_frame')]/*[@id='projektbeschreibung']"):   
     lianjia = lianjiaItem() 
     lianjia['Projekttitel'] = sel.xpath("//div/div/span/text()").extract() 

回答

0

此XPath

response.xpath("//span[contains(., 'beteiligter Wissenschaftler')]/following-sibling::span[@class='value']/a/text()").extract() 

回报教授阵列。第一个是Professor Dr. Michael Eiermann

+0

@DaniiilMashkin sel.xpath声明(Projekttitel),保持不变? – user3786117

+0

不,xpath返回字符串数组,您不需要使用另一个xpath。 –