1 #! /usr/bin/python 2 # -*- coding: utf-8 -*- 3 4 # Fonctionne sous Python 2 5 import urllib2, re 6 7 the_url = 'http://www.croire.com' 8 req = urllib2.Request(the_url) 9 handle = urllib2.urlopen(req) 10 the_page = handle.read() 11 12 motif = "info-day-block\">" 13 nbChunksPlusLoin = 9 14 15 chunks = the_page.split() 16 #index(...) 17 # L.index(value, [start, [stop]]) -> integer -- return first index of value. 18 # Raises ValueError if the value is not present. 19 20 ind = chunks.index(motif) #indice du chunk ds la page 21 22 saint = chunks[ind + nbChunksPlusLoin] # 9 chunks + loin 23 saint = re.sub("", '', saint) 24 print saint