Exemplo n.º 1
0
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Interpreter version: python 2.7
#
# Imports =====================================================================
from collections import namedtuple

import dhtmlparser  # pip install -U dhtmlparser
from httpkie import Downloader  # pip install -U httpkie

# Variables ===================================================================
downloader = Downloader()
MIPSInfo = namedtuple("MIPSInfo", "name mips year")


# Functions & classes =========================================================
def get_table():
    page = downloader.download(
        "https://en.wikipedia.org/wiki/Instructions_per_second")

    dom = dhtmlparser.parseString(page)

    return dom.find("table", {"class": "wikitable sortable"})[0]


def parse_table():
    for tr in get_table().find("tr"):
        tds = tr.find("td")

        if not tds: