def urlExtractData(url, defs):
    """
    Get html from url, parse according to defs, return as dictionary
    defs is a list of tuples ("name", "xpath", "regex", fn )
      name becomes the key in the returned dictionary
      xpath is used to extract a string from the page
      regex further processes the string (skipped if None)
      fn casts the string to the desired type (skipped if None)
    """
page = urllib.request.urlopen(url)
tree = lxml.html.parse(page)
res = {}
Скачать цены с python