I am trying to make this piece of code to work, so that I can scrapy some columns of a table from the website below: http://www.chiptiming.com.br/resultados/detalhes/2213609473
I have been trying to modify a lot of things in order to work, but no sucess, can anyone tell me what am I doing wrong? I put the log as well. Thanks in advance.
ps: I have read many posts similar to mine, but I couldn't find what is the reason, sorry if this post is kind of repeated.
from scrapy import Spider
from scrapy.selector import Selector
from stack.items import StackItem
class StackSpider(Spider):
name = "stack"
allowed_domains = ["chiptiming.com.br"]
start_urls =
['http://www.chiptiming.com.br/resultados/detalhes/2213609473',]
def parse(self, response):
products = response.xpath('//*[@id="uptPnlResultGrid"]/div/table//tr')
# ignore the table header row
for product in products[1:]:
item = StackItem()
item['Coloc'] = product.xpath('td[1]//text()').extract_first()
item['NumPeito'] = product.xpath('td[2]//text()').extract_first()
item['Nome'] = product.xpath('td[3]//text()').extract_first()
yield item
D:\Python\stack>python -m scrapy crawl stack -o items_corrida.json -t json 2018-02-10 16:19:04 [scrapy.utils.log] INFO: Scrapy 1.5.0 started (bot: stack) 2018-02-10 16:19:04 [scrapy.utils.log] INFO: Versions: lxml 4.1.0.0, libxml2 2.9.4, cssselect 1.0.3, parsel 1.4.0, w3lib 1.19.0, Twisted 17.9.0, Python 3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)], pyOpenSSL 17.2.0 (OpenSSL 1.0.2l 25 May 2017), cryptography 2.0.3, Platform Windows-10-10.0.16299-SP0 2018-02-10 16:19:04 [scrapy.crawler] INFO: Overridden settings: {'BOT_NAME': 'stack', 'FEED_FORMAT': 'json', 'FEED_URI': 'items_corrida.json', 'NEWSPIDER_MODULE': 'stack.spiders', 'ROBOTSTXT_OBEY': True, 'SPIDER_MODULES': ['stack.spiders']} 2018-02-10 16:19:04 [scrapy.middleware] INFO: Enabled extensions: ['scrapy.extensions.corestats.CoreStats', 'scrapy.extensions.telnet.TelnetConsole', 'scrapy.extensions.feedexport.FeedExporter', 'scrapy.extensions.logstats.LogStats'] 2018-02-10 16:19:04 [scrapy.middleware] INFO: Enabled downloader middlewares: ['scrapy.downloadermiddlewares.robotstxt.RobotsTxtMiddleware', 'scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware', 'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware', 'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware', 'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware', 'scrapy.downloadermiddlewares.retry.RetryMiddleware', 'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware', 'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware', 'scrapy.downloadermiddlewares.redirect.RedirectMiddleware', 'scrapy.downloadermiddlewares.cookies.CookiesMiddleware', 'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware', 'scrapy.downloadermiddlewares.stats.DownloaderStats'] 2018-02-10 16:19:04 [scrapy.middleware] INFO: Enabled spider middlewares: ['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware', 'scrapy.spidermiddlewares.offsite.OffsiteMiddleware', 'scrapy.spidermiddlewares.referer.RefererMiddleware', 'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware', 'scrapy.spidermiddlewares.depth.DepthMiddleware'] 2018-02-10 16:19:04 [scrapy.middleware] INFO: Enabled item pipelines: [] 2018-02-10 16:19:04 [scrapy.core.engine] INFO: Spider opened 2018-02-10 16:19:04 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min) 2018-02-10 16:19:04 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6024 2018-02-10 16:19:04 [scrapy.downloadermiddlewares.redirect] DEBUG: Redirecting (302) to http://www.chiptiming.com.br/404.aspx> from http://www.chiptiming.com.br/robots.txt> 2018-02-10 16:19:04 [scrapy.core.engine] DEBUG: Crawled (200) http://www.chiptiming.com.br/404.aspx> (referer: None) 2018-02-10 16:19:04 [scrapy.core.engine] DEBUG: Crawled (200) http://www.chiptiming.com.br/resultados/detalhes/2213609473> (referer: None) 2018-02-10 16:19:04 [scrapy.core.engine] INFO: Closing spider (finished) 2018-02-10 16:19:04 [scrapy.statscollectors] INFO: Dumping Scrapy stats: {'downloader/request_bytes': 880, 'downloader/request_count': 3, 'downloader/request_method_count/GET': 3, 'downloader/response_bytes': 17534, 'downloader/response_count': 3, 'downloader/response_status_count/200': 2, 'downloader/response_status_count/302': 1, 'finish_reason': 'finished', 'finish_time': datetime.datetime(2018, 2, 10, 18, 19, 4, 768123), 'log_count/DEBUG': 4, 'log_count/INFO': 7, 'response_received_count': 2, 'scheduler/dequeued': 1, 'scheduler/dequeued/memory': 1, 'scheduler/enqueued': 1, 'scheduler/enqueued/memory': 1, 'start_time': datetime.datetime(2018, 2, 10, 18, 19, 4, 319337)} 2018-02-10 16:19:04 [scrapy.core.engine] INFO: Spider closed (finished)
Ctrl+U
in your browser). It's loaded through AJAX call (POST
to chiptiming.com.br/resultados/detalhes/2213609473 ) – gangabass