我一直在这个困难的时间。Scrapy,从StubHub刮来的价格数据
我想刮掉在好莱坞碗的布鲁诺火星演唱会上列出的所有价格,这样我就可以得到平均价格。
http://www.stubhub.com/bruno-mars-tickets/bruno-mars-hollywood-hollywood-bowl-31-5-2014-4449604/
我已经位于HTML中的价格和XPath是非常简单的,但我不能让任何值返回。
我认为它与通过javascript或ajax生成的内容有关,但我无法弄清楚如何发送正确的请求来使代码正常工作。
这是我有:
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
任何帮助将不胜感激我一直是这样一个苦苦挣扎相当一段时间。 预先感谢您!
我想你想要的是从返回JSON的API调用中获取:https://www.stubhub.com/ticketAPI/restSvc/event/4449604/sort/price/0?ts=1396358054406 –