python - Scrapy not able to extract links -
i have written crawler extract links , text webpage. structure of content
div - ul - li - a
here code
from scrapy import spider scrapy.selector import selector stack.items import stackitem class stackspider(spider): name = "stack" allowed_domains = ["stackoverflow.com"] start_urls = [ "http://page.com", ] def parse(self, response): documents = selector(response).xpath('//*[@id="node-329"]/div[1]/ul/li') document in documents: item = stackitem() item['title'] = document.xpath('./a/text()').extract() item['link'] = document.xpath('/a/@href').extract() yield item
basically, tag /a/@href not working. if comment , try extract text, works.
please me.
Comments
Post a Comment