@@ -0,0 +1,2485 @@
+import scrapy%0A%0A%0Aclass ReadabilitySpider(scrapy.Spider):%0A    name = %22readability%22%0A%0A    login_url = 'https://www.readability.com/login/'%0A    reading_list_url = 'https://www.readability.com/reading-list?page=%7B0%7D'%0A    archive_list_url = (%0A        'https://www.readability.com/reading-list/archives?page=%7B0%7D'%0A    )%0A%0A    # Utility Functions%0A%0A    def make_readability_list_link(self, number=1):%0A        return self.reading_list_url.format(number)%0A%0A    def make_readability_archive_link(self, number=1):%0A        return self.archive_list_url.format(number)%0A%0A    def get_page_number_from_url(self, url):%0A        return int(url.split('=')%5B1%5D)%0A%0A    def make_page_json_name(self, url):%0A        current_page_number = self.get_page_number_from_url(url)%0A        if 'archive' in url:%0A            return 'archive_page_%7B%7D_links'.format(current_page_number)%0A        else:%0A            return 'page_%7B%7D_links'.format(current_page_number)%0A%0A    def get_next_page_link(self, response):%0A        next_page_query = (%0A            response%0A            .xpath('//a%5Bcontains(@class, %22page-older%22)%5D/@href')%0A            .extract_first()%0A        )%0A        if next_page_query is not None:%0A            page_number = self.get_page_number_from_url(next_page_query)%0A            if 'archive' in response.url:%0A                return self.make_readability_archive_link(page_number)%0A            else:%0A                return self.make_readability_list_link(page_number)%0A        return None%0A%0A    # Spider Functionality%0A%0A    def start_requests(self):%0A        yield scrapy.Request(self.login_url, callback=self.submit_login_form)%0A%0A    def submit_login_form(self, response):%0A        # login to response form%0A        yield scrapy.FormRequest.from_response(%0A            response,%0A            formdata=%7B%0A                'username': self.username,%0A                'password': self.password,%0A            %7D,%0A            callback=self.start_crawl,%0A        )%0A%0A    def start_crawl(self, response):%0A        yield scrapy.Request(self.make_readability_list_link())%0A        yield scrapy.Request(self.make_readability_archive_link())%0A%0A    def parse(self, response):%0A        reading_list = (%0A            response%0A            .xpath('//a%5Bcontains(@class, %22article-origin%22)%5D/@href')%0A            .extract()%0A        )%0A        yield %7B%0A            self.make_page_json_name(response.url): reading_list,%0A        %7D%0A        next_page_url = self.get_next_page_link(response)%0A        if next_page_url is not None:%0A            yield scrapy.Request(next_page_url)%0A

Implement readability spider