[EMAIL PROTECTED] wrote: > 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)
You just have to find some kind of ad hoc search that gets you to where you want to be. I would try something like this: anchor = soup.fetch('a', dict(href="/wiki/List_of_country_calling_codes")) code = anchor.findNext('code') print code.string Presumably you want this to work for other country pages as well; you will have to look at the source, see what they have in common and search on that. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor