Covering array scraper and sorter
Here are some of the quick performance wins you may get:


switch to using requests and reuse a Session instance which should provide a performance boost:


  if you're making several requests to the same host, the underlying TCP
  connection will be reused, which can result in a significant
  performance increase (see HTTP persistent connection).


import requests

session = requests.Session()

# iterate over v, t in the known table ranges
for v in range(2, 26):
    for t in range(2, 7):
        # download the webpage and find the elements
        url = "http://www.public.asu.edu/~ccolbou/src/tabby/%d-%d-ca.html" % (t, v)
        response = session.get(url)

use the fastest available underlying parser - lxml (requires to install lxml):

soup = BeautifulSoup(response, 'lxml')

parse only table elements from a page source via SoupStrainer:

parse_only = SoupStrainer('table')
soup = BeautifulSoup(response, 'lxml', parse_only=parse_only)


Requires importing SoupStrainer from bs4.


And, applying some bs4 related shortcuts, the HTML parsing part would transform into:

table = soup.table
for row in table('tr'):
    elements = []
    for cell in row('td'):
        value = cell.string
        if value is not None and value not in ("k", "N", "Source"):
            elements.append(value)