Find the number of pages paginating a genre's letter URL

def _find_num_pages(self, url):
    """
    Find the number of pages paginating a genre's letter URL
    """
    def _new_url(i):
      return '{}&page={}#page'.format(url, i)
    i = 0
    j = 2000
    k = (i + j) / 2
    crawler = SeriesCrawler(_new_url(k))
    while i < j:
      ids = crawler.get_ids()
      # If we only find one (we've gone too far)
      if len(ids) == 1:
        # Don't decrement by 1 b/c this could be the last page
        j = k
        k = (i + j) / 2
        crawler.set_url(_new_url(k))
      else:
        i = k + 1
        k = (i + j) / 2
        crawler.set_url(_new_url(k))
    return i