Split a comma separated list with links in with beautifulsoup?

This is one way you could do it: import BeautifulSoup soup = BeautifulSoup. BeautifulSoup(''' Names Fred, John, Barry, Roger, James ''') result = for tag in soup.table. FindAll('td')1: if isinstance(tag, BeautifulSoup.

NavigableString): for name in tag.string. Split(','): name = name.strip() if name: result. Append({ 'name': name }) else: result.

Append({ 'name': tag.string.strip(), 'url': tag"href" }) print result.

1 nice solution – vikingosegundo Dec 2 '09 at 18:57 +1 its really cool – atv Dec 2 '09 at 21:42 Nice solution indeed! One small note: I would replace "type(tag) is BeautifulSoup. NavigableString" with "isinstance(tag, BeautifulSoup.

NavigableString)". – taleinat Dec 5 '09 at 2:07 I updated it with your suggestion. – Mark Byers Dec 5 '09 at 2:35.

Soup = BeautifulSoup. For tag in soup.table. If isinstance(tag, BeautifulSoup.

For name in tag.string.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions