def next_index_page_url(url, pagination_index)
      return url unless @paginated

      if pagination_index > @pagination_max_pages
        puts "Exceeded pagination limit of #{@pagination_max_pages}" if @verbose
        EMPTY_STRING
      else
        uri = URI.parse(url)
        query = uri.query ? Hash[URI.decode_www_form(uri.query)] : {}
        # update the pagination query string parameter
        query[@pagination_param] = pagination_index
        uri.query = URI.encode_www_form(query)
        puts "Next index pagination url is #{uri}" if @verbose
        uri.to_s
      end
    end
def next_index_page_url(url, pagination_index)
      return url unless @paginated

      if pagination_index > @pagination_max_pages
        puts "Exceeded pagination limit of #{@pagination_max_pages}" if @verbose
        EMPTY_STRING
      else
        uri = URI.parse(url)
        query = uri.query ? Hash[URI.decode_www_form(uri.query)] : {}
        # update the pagination query string parameter
        query[@pagination_param] = pagination_index
        uri.query = URI.encode_www_form(query)
        puts "Next index pagination url is #{uri}" if @verbose
        uri.to_s
      end
    end
Return the next URL to scrape, given the current URL and its index.

 Recursion stops if the fetching URL returns an empty string or an error.

 If @paginated is not set (the default), this method returns an empty string.

 If @paginated is set, this method will return the next pagination URL
 to scrape using @pagination_param and the pagination_index.

 If the pagination_index is greater than @pagination_max_pages, then the
 method will return an empty string.

 Override this method to handle pagination is an alternative way
 e.g. next_index_page_url("http://whatever.com/articles?page=1", 2)
 ought to return "http://whatever.com/articles?page=2"