from urllib request import urlopen import sys class printlinks(htmlparser)def handle_starttag(self,tag,attrs)if tag =' 'for name,value in attrsif name ='href'print(valuep printlinks( urlopen(sys argv[ ]data read(charset info(getparam('charset'#charset info(get_content_charset( feed(data decode(charset) close(python python in the exampleit must be noted that any html fetched using urllib is returned as byte string to properly parse itit must be decoded into text according to the document character set encoding the example shows how to obtain this in python and python note the parsing capabilities of htmlparser tend to be rather limited in factwith very complicated and/or malformed htmlthe parser can break users also find this module to be lower-level than is useful if you are writing programs that must scrape data from html pagesconsider the beautiful soup package (pypi/beautifulsoupjson the json module is used to serialize and unserialize objects represented using javascript object notation (jsonmore information about json is available at incidentallyit' almost the same as python syntax for representing lists and dictionaries for examplea json array is written as [value value ]and json object is written as {name:valuename:valuethe following list shows how json values and python values are mapped the python types listed in parentheses are accepted when encoding but are not returned when decoding (insteadthe first listed type is returnedjson type python type object array string number true false null dict list (tupleunicode (strbytesintfloat true false none lib fl ff