我想获得href
代码的<a>
。
我试过了;
def parse(self, response):
sel = Selector(response)
sites = sel.xpath('.//div[@class="aaaaaaaaaa"]/h3/span/a')
for site in sites:
Link = site.get_attribute('href')
print Link
但我知道了:
请帮忙 exceptions.AttributeError:'Selector'对象没有属性'get_attribute答案 0 :(得分:3)
你可以这样做:
def parse(self, response):
sel = Selector(response)
sites = sel.xpath('.//div[@class="block item-title"]/h3/span/a')
for site in sites:
Link = site.xpath('@href').extract()[0]
print Link