Xpath取得的元素element二級檢索,二次檢索

temp_ls=Selector.xpath("//tr/td[@class='keyword']/a[@class='list-title']")

for index,i in enumerate(temp_ls):
    tempDict={}
    tempDict['title']=i.xpath("./text()")[0]
    tempDict['url']=i.xpath("./@href")[0]
    newsDict['newList'].append(tempDict)

同級標籤下匹配,加  ./

多級加./a./b  等

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章