[Tutor] using BeautifulSoup

jonasmg at softhome.net jonasmg at softhome.net
Mon Mar 27 16:57:01 CEST 2006


Hi! 

I'm trying to use BeautifulSoup for get data from a table (on right) from:
http://en.wikipedia.org/wiki/United_states 

i.e. i would get data from 'Calling code' that it would be '+1' 

 ---------------------- 

import urllib2
from BeautifulSoup import BeautifulSoup 

url="http://en.wikipedia.org/wiki/United_states"
html = urllib2.urlopen(url).read()
soup = BeautifulSoup()
soup.feed(html) 

mainTable = soup.first('table')
rows = mainTable('tr') 


any help here? 

Thanks in advance 


More information about the Tutor mailing list