I am using scrapy to scrap a site
I had written a spider and fetched all the items from the page and saved to a csv file,
and now i want to save the total exec
The easiest way I've found so far:
import scrapy
class StackoverflowSpider(scrapy.Spider):
name = "stackoverflow"
start_urls = ['https://stackoverflow.com/questions/tagged/web-scraping']
def parse(self, response):
for title in response.css(".summary .question-hyperlink::text").getall():
yield {"Title":title}
def close(self, reason):
start_time = self.crawler.stats.get_value('start_time')
finish_time = self.crawler.stats.get_value('finish_time')
print("Total run time: ", finish_time-start_time)