/ Published in: Python
Simple web parser using urllib and re libs.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import urllib, re url = 'http://www.viedemerde.fr/aleatoire' page = urllib.urlopen(url).read() parse = re.findall("\<div class=\"post article\" id=\"(.+?)\">(.+?)</div", page) for article in parse: parse1 = re.findall("\<a href=\"(.+?)" + article[0] + "\" class=\"fmllink\">(.+?)</a>", article[1]) vdm = '' for test in parse1: vdm += test[1] print("http://viedemerde.fr/"+article[0]+" : "+vdm)