Here's one way to do it:
import re
_any_re = re.compile('.+')
d = {}
for row in BeautifulSoup(html).fetch('tr'):
columns = row.fetch('td')
field = columns[1].firstText(_any_re).rstrip(' \t\n:')
value = ' '.join(text.rstrip()
for text in columns[2].fetchText(_an
Maybe a more robust approach is just to walk through the string
counting the (increments) of the number of brackets "<" and ">" as you
know that all the relevant text occurs right after a ">" has occured
that sets your counter to 0 (meaning you're at the "highest level").
There's no relevant text i
rh0dium wrote:
> Hi all,
>
> I am trying to parse into a dictionary a table and I am having all
> kinds of fun. Can someone please help me out.
>
> What I want is this:
>
> dic={'Division Code':'SALS','Employee':'LOO ABLE'}
>
> Here is what I have..
>
> html=""" src="/icons/ecblank.gif"
Hi all,
I am trying to parse into a dictionary a table and I am having all
kinds of fun. Can someone please help me out.
What I want is this:
dic={'Division Code':'SALS','Employee':'LOO ABLE'}
Here is what I have..
html=""" Division Code:
SALS Employee:
LOO ABLE """
from Beautiful