Scrapy use to parse an html. My question is why sometimes my back scrapy response to what I want, but sometimes does not return a response. Is it my fault? Here's how seems parsing function.
class AmazonSpider(BaseSpider):
name = "amazon"
allowed_domains = ["amazon.org"]
start_urls = [
"http://www.amazon.com/s?rh=n%3A283155%2Cp_n_feature_browse-bin%3A2656020011"
]
def parse(self, response):
sel = Selector(response)
sites = sel.xpath('//div[contains(@class, "result")]')
items = []
titles = {'titles': sites[0].xpath('//a[@class="title"]/text()').extract()}
for title in titles['titles']:
item = AmazonScrapyItem()
item['title'] = title
items.append(item)
return items