Refatored code to fit scrapy framework.