2017-10-12 99 views
-1
<div class="breadcrumbs pt10 pb10"> 
<a>Location :</a> 
"National Harbor     , 
       Maryland" 
<br> 
<a href="#" class="type">Venue : </a> 
"Gaylord National Resort & Convention Center " 
</div> 

如何獲取文本馬里蘭州蓋洛德國家度假村國家海港&從上面的Python會議中心使用scrapy?如何從python中的'a'標籤中使用scrapy獲取文本?

回答

0

你可以看一下scrapy selectors

達到你想要的頁面上的所有錨標籤,你可以用什麼:

link_text_list = response.selector.xpath('//a/text()').extract() 
+0

我應用這個代碼..「response.selector.xpath('//div [@ class =「breadcrumbs pt10 pb10」]/a/text()')。extract()「....但o/p我越來越喜歡這個..」[u'Location:',u 'Venue:']「 – rajeshbojja

+0

@ surfer190..can you please give me reply for above one ..? – rajeshbojja

+0

字符串前面的「u」表示「unicode」。這可能是'python 2.7'最好使用python'3.6' – surfer190

相關問題