Minimalist and powerful Web Crawler.
Python Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Minimalist and powerful Web Crawler.

Sukhoi is built on top of the concept of miners, it is similar to what happens with scrapy and its spiders. However, in sukhoi the miners can be placed in structures like lists or dictionaries in order to construct json-like structures for the data thats extracted from the pages.


  • Http/https support

  • Short learning curve

  • Extremely fast

  • GET/POST requests

  • Basic AUTH support

  • Modular

  • Support for LXML

  • Support for BeautifulSoup4

  • Non-blocking I/O

Basic example

The basic example below is equivalent to scrapy's main example although it not only scrapes the author's name but its complete description that stays a layer down from the quotes's pages.

Miners inherit from python list class, so they can be used to accumulate data from the pages, they can be placed anywhere too(in this way it is highly flexible to construct json structures for your fetched data.)

from sukhoi import MinerLXML, core

class AuthorMiner(MinerLXML):
    def run(self, dom):
        # The dom object is a struct returned by fromstring.
        # from lxml.html import fromstring
        # dom = fromstring(data)
        # See:
        # Grab the text for the author description
        # and accumulate it.
        elems = dom.xpath("//div[@class='author-description']")

class QuoteMiner(MinerLXML):
    def run(self, dom):
        # Grab all the quotes.
        elems = dom.xpath("//div[@class='quote']")
        self.extend(list(map(self.extract_quote, elems)))

        # Grab the link that points to the next page.
        next_page = dom.xpath("//li[@class='next']/a[@href][1]")
        # If there is a next page then flies there to extract
        # the quotes.
        if next_page:[0].get('href'))

    def extract_quote(self, elem):
        # Grab the quote text.
        quote = elem.xpath(".//span[@class='text']")[0].text

        # Grab the url description.
        author_url = elem.xpath(".//a[@href][1]")[0].get('href')

        # Return the desired structure, and tells AuthorMiner to fly
        # to the url that contains the author description.
        return {'quote': quote, 

if __name__ == '__main__':
    URL = ''
    quotes = QuoteMiner(URL)

    # As miners inherit from lists, you end up with
    # the desired structure containg the quotes and the
    # author descriptions.

The above code would output a json structure like:

[{'quote': 'The quote extracted.', 
'author': 'The autor description from the about link.'}, ...]

Notice the above code differs slightly from main scrapy example because it catches not just the name of the author but the complete description of the author thats found from the link whose text is "about".

You can use either EHP or lxml with sukhoi.

Sukhoi permits one to split up the parsing into miners in a succint way that permits clean and consistent code. Miners can receive pool objects that are used to accurately construct the desired data structure.

The example below scrapes all the tags from by following pagination then makes sure they are unique then scrapes all the quotes from them with their author description. The example below uses EHP to extract the data from the htmls.

from sukhoi import MinerEHP, core

class AuthorMiner(MinerEHP):
    def run(self, dom):
        elem = dom.fst('div', ('class', 'author-description'))

class QuoteMiner(MinerEHP):
    def run(self, dom):
        elems = dom.find('div', ('class', 'quote'))
        self.extend(list(map(self.extract_quote, elems)))

        elem = dom.fst('li', ('class', 'next'))
        if elem:'a').attr['href'])

    def extract_quote(self, elem):
        quote = elem.fst('span', ('class', 'text'))
        author_url = elem.fst('a').attr['href']

        return {'quote': quote.text(), 

class TagMiner(MinerEHP):
    acc = set()

    def run(self, dom):
        tags = dom.find('a', ('class', 'tag'))

        ind.attr['href']) for ind in tags])

        elem = dom.fst('li', ('class', 'next'))

        if elem: 
    def extract_quotes(self):
        QuoteMiner(self.geturl(ind[1]))) for ind in self.acc])

if __name__ == '__main__':
    URL = ''
    tags = TagMiner(URL)


The structure would look like:

[(tag_name, {'quote': 'The quote text.', 'author': "The author description from the about link'}), ...]

This other example uses beautifulsoup4 to extract merely the quotes. It follows pagination as well.

from sukhoi import MinerBS4, core

class QuoteMiner(MinerBS4):
    def run(self, dom):
        elems = dom.find_all('div', {'class':'quote'})
        self.extend(list(map(self.extract_quote, elems)))

        elem = dom.find('li', {'class', 'next'})
        if elem:'a').get('href'))

    def extract_quote(self, elem):
        quote = elem.find('span', {'class': 'text'})
        return quote.text

if __name__ == '__main__':
    URL = ''
    quotes = QuoteMiner(URL)


The structure would be:

[quote0, quote1, ...]


Note: Sukhoi would work on python3 only, python2 support was dropped.

pip install -r requirements.txt
pip install sukhoi



Note: If sukhoi was useful to you and you feel likely supporting it, please, consider opening an issue about a donation :)