I'm trying to run a spider which grabs certain pieces of information from http://www.hltv.org/?pageid=188&eventid=0&gameid=2 and creates a .csv file with the data. I'd like the spider to go through each date and scrape key pieces of information for each listed date: http://www.hltv.org/?pageid=188&matchid=19029&eventid=0&gameid=2
This is what I have so far:
import scrapy
class hltvspider(scrapy.Spider):
name = "hltvspider"
allowed_domains = ["hltv.org"]
start_urls = ["http://www.hltv.org/?pageid=188&eventid=0&gameid=2"]
def parse(self, response):
for sel in response.xpath('//ul/li'):
title = sel.xpath('a/text()').extract()
link = sel.xpath('a/@href').extract()
desc = sel.xpath('text()').extract()
print title, link, desc
Here is the output I get:
C:\Users\Michael\PycharmProjects\HLTV\HLTV\HLTV\spiders\hltv.py:5: ScrapyDeprecationWarning: HLTV.spiders.hltv.MySpider inherits from deprecated class scrapy.spider.BaseSpider, please inhe
rit from scrapy.spider.Spider. (warning only on first subclass, there may be others)
2015-01-21 16:20:22-0600 [scrapy] INFO: Scrapy 0.24.4 started (bot: HLTV)
2015-01-21 16:20:22-0600 [scrapy] INFO: Optional features available: ssl, http11
2015-01-21 16:20:22-0600 [scrapy] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'HLTV.spiders', 'SPIDER_MODULES': ['HLTV.spiders'], 'BOT_NAME': 'HLTV'}
2015-01-21 16:20:22-0600 [scrapy] INFO: Enabled extensions: LogStats, TelnetConsole, CloseSpider, WebService, CoreStats, SpiderState
2015-01-21 16:20:22-0600 [scrapy] INFO: Enabled downloader middlewares: HttpAuthMiddleware, DownloadTimeoutMiddleware, UserAgentMiddleware, RetryMiddleware, DefaultHeadersMiddleware, MetaR
efreshMiddleware, HttpCompressionMiddleware, RedirectMiddleware, CookiesMiddleware, ChunkedTransferMiddleware, DownloaderStats
2015-01-21 16:20:22-0600 [scrapy] INFO: Enabled spider middlewares: HttpErrorMiddleware, OffsiteMiddleware, RefererMiddleware, UrlLengthMiddleware, DepthMiddleware
2015-01-21 16:20:22-0600 [scrapy] INFO: Enabled item pipelines:
2015-01-21 16:20:22-0600 [hltvspider] INFO: Spider opened
2015-01-21 16:20:22-0600 [hltvspider] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2015-01-21 16:20:22-0600 [scrapy] DEBUG: Telnet console listening on 127.0.0.1:6023
2015-01-21 16:20:22-0600 [scrapy] DEBUG: Web service listening on 127.0.0.1:6080
2015-01-21 16:20:23-0600 [hltvspider] DEBUG: Crawled (200) <GET http://www.hltv.org/?pageid=188&eventid=0&gameid=2> (referer: None)
[] [] [u'\n\t\t\t\t', u'\n\t\t\t\t', u'\n\t\t\t']
[] [] [u'\n\t\t\t\t', u'\n\t\t\t\t', u'\n\t\t\t']
[] [] [u'\n\t\t\t\t', u'\n\t\t\t\t', u'\n\t\t\t']
[] [] [u'\n\t\t\t\t', u'\n\t\t\t\t', u'\n\t\t\t']
[] [] [u'\n\t\t\t\t', u'\n\t\t\t\t', u'\n\t\t\t']
[] [] [u'\n\t\t\t\t', u'\n\t\t\t\t', u'\n\t\t\t\t']
[] [] [u'\n\t\t\t\t', u'\n\t\t\t\t', u'\n\t\t\t\t']
[] [] [u'\n ', u'\n ', u'\n ']
[] [] [u'\n\t\t\t\t\t', u'\n\t\t\t\t\t', u'\n\t\t\t\t']
[] [] [u'\n\t\t\t\t\t', u'\n\t\t\t\t\t', u'\n\t\t\t\t']
2015-01-21 16:20:23-0600 [hltvspider] INFO: Closing spider (finished)
2015-01-21 16:20:23-0600 [hltvspider] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 241,
'downloader/request_count': 1,
'downloader/request_method_count/GET': 1,
'downloader/response_bytes': 13544,
'downloader/response_count': 1,
'downloader/response_status_count/200': 1,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2015, 1, 21, 22, 20, 23, 432000),
'log_count/DEBUG': 3,
'log_count/INFO': 7,
'response_received_count': 1,
'scheduler/dequeued': 1,
'scheduler/dequeued/memory': 1,
'scheduler/enqueued': 1,
'scheduler/enqueued/memory': 1,
'start_time': datetime.datetime(2015, 1, 21, 22, 20, 22, 775000)}
2015-01-21 16:20:23-0600 [hltvspider] INFO: Spider closed (finished)