scraping nested tables with BeautifulSoup

Gonzillaaa at gmail.com Gonzillaaa at gmail.com
Tue Apr 4 05:18:54 EDT 2006


I'm trying to get the data on the "Central London Property Price Guide"
box at the left hand side of this page
http://www.findaproperty.com/regi0018.html

I have managed to get the data :) but when I start looking for tables I
only get tables of depth 1 how do I go about accessing inner tables?
same happens for links...

this is what I've go so far

import sys
from urllib import urlopen
from BeautifulSoup import BeautifulSoup

data = urlopen('http://www.findaproperty.com/regi0018.html').read()
soup = BeautifulSoup(data)

for tables in soup('table'):
	table = tables('table')
	if not table: continue
	print table #this returns only 1 table

#this doesn't work at all

	nested_table = table('table')
	print nested_table

all suggestions welcome




More information about the Python-list mailing list