Question

i want to get the href of the <a> tag.

I tried this;

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

but I got that:

help please exceptions.AttributeError: 'Selector' object has no attribute 'get_attribute

Was it helpful?

Solution

You can do this:

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top