Tuesday, May 5, 2009
Given a URL of a web page, extract all the URLs from that web page. Do this in one line. Assume that URLs in the web page are of the form <a href="...">...</a>. Bonus Question: also return the text in the <a>text</a> tag for the given URL.
Write a one line Python function to format a big integer into fixed sized byte representation such that 0x0102030405 gets converted to '\x00\x00\x00\x01\x02\x03\x04\x05'. You cannot use struct module as it is limited to 32 bit number. Such functions are useful when dealing with SHA1/MD5 or crypto/RSA routines.
Give a one line statement in python to parse a HTTP or SIP header value of the form "Header1: Value1\r\nHeader2: Value2:\r\n" by returning a tuple (('Header1', 'Value1'), ('Header2', 'Value2'). Bonus question: what are the problem in returning a dict instead?