I've been having a difficult time with this one.
I want to scrape all the prices listed for this Bruno Mars concert at the Hollywood Bowl so I can get the average price.
http://www.stubhub.com/bruno-mars-tickets/bruno-mars-hollywood-hollywood-bowl-31-5-2014-4449604/
I've located the prices in the HTML and the xpath is pretty straightforward but I cannot get any values to return.
I think it has something to do with the content being generated via javascript or ajax but I can't figure out how to send the correct request to get the code to work.
Here's what I have:
from scrapy.spider import BaseSpider
from scrapy.selector import Selector
from deeptix.items import DeeptixItem
class TicketSpider(BaseSpider):
name = "deeptix"
allowed_domains = ["stubhub.com"]
start_urls = ["http://www.stubhub.com/bruno-mars-tickets/bruno-mars-hollywood-hollywood-bowl-31-5-2014-4449604/"]
def parse(self, response):
sel = Selector(response)
sites = sel.xpath('//div[contains(@class, "q_cont")]')
items = []
for site in sites:
item = DeeptixItem()
item['price'] = site.xpath('span[contains(@class, "q")]/text()').extract()
items.append(item)
return items
Any help would be greatly appreciated I've been struggling with this one for quite some time now. Thank you in advance!
Source: http://stackoverflow.com/questions/22770917/scrapy-scraping-price-data-from-stubhub
No comments:
Post a Comment