Python HTML Parsing

Lama tak update blog ini. Tak terasa sudah 6 tahun usia blog ini, tepatnya bulan November tahun lalu.

Saya cuma mau masang code ini aja 😀

from lxml.html import parse
doc = parse('http://www.google.com').getroot()


for link in doc.cssselect('div.metadata h1 a'):
print '%s: %s' % (link.text_content(), link.get('href'))