Re: [Tutor] BeautifulSoup - getting cells without new line characters

2006-04-02 Thread jonasmg
Danny Yoo writes: > > >> And the solution to get the state and capital columns (where there are >> anchors): >> >> for row in table('tr'): >>for cell in row.fetch('a')[0:2]: >>print cell.string > > Hi Jonas, > > That's good to hear! So does everything work for you then? > N

Re: [Tutor] BeautifulSoup - getting cells without new line characters

2006-04-01 Thread jonasmg
And the solution to get the state and capital columns (where there are anchors): for row in table('tr'): for cell in row.fetch('a')[0:2]: print cell.string ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] BeautifulSoup - getting cells without new line characters

2006-04-01 Thread jonasmg
Danny Yoo writes: > > >> > Have you read a Python tutorial? It seems like some of the things you >> > are struggling with might be addressed in general Python material. >> >> >> You consider a thing about me. If I ask something it is because I cannot >> find the solution. I do not it by whim.

Re: [Tutor] BeautifulSoup - getting cells without new line characters

2006-04-01 Thread jonasmg
Kent Johnson writes: > [EMAIL PROTECTED] wrote: >> Yes, ok. But so, it is only possible get data from a row (rows[0]) >> >> cells=rows[0]('td') >> >> And I want get data from all rows. I have trying with several 'for' setences >> but i can not. > > Can you show us what you tried? > > H

Re: [Tutor] BeautifulSoup - getting cells without new line characters

2006-04-01 Thread jonasmg
Kent Johnson writes: > [EMAIL PROTECTED] wrote: >> Kent Johnson writes: >> >> >>>[EMAIL PROTECTED] wrote: >>> >>> List of states: http://en.wikipedia.org/wiki/U.S._state : soup = BeautifulSoup(html) : # Get the second table (list of states). : table = soup.first(

Re: [Tutor] BeautifulSoup - getting cells without new line characters

2006-03-31 Thread jonasmg
Kent Johnson writes: > [EMAIL PROTECTED] wrote: > >> List of states: >> http://en.wikipedia.org/wiki/U.S._state >> >> : soup = BeautifulSoup(html) >> : # Get the second table (list of states). >> : table = soup.first('table').findNext('table') >> : print table >> >> ... >> >> WY >> Wyo.

Re: [Tutor] BeautifulSoup - getting cells without new line characters

2006-03-31 Thread jonasmg
Kent Johnson writes: > [EMAIL PROTECTED] wrote: >> You have reason but the problem is that some cells have anchors. >> Sorry, I forgot myself to say it. >> >> and using: >> >> for row in table('tr'): >> cellText = [cell.string for cell in row('td')] >> print cellText >> >> I get

Re: [Tutor] BeautifulSoup - getting cells without new line characters

2006-03-31 Thread jonasmg
Kent Johnson writes: > [EMAIL PROTECTED] wrote: >> Kent Johnson writes: >> >> >>>[EMAIL PROTECTED] wrote: >>> From a table, I want to get the cells for then only choose some of them. WY Wyo. ... Using: for row in table('tr'

Re: [Tutor] BeautifulSoup - getting cells without new line characters

2006-03-31 Thread jonasmg
Kent Johnson writes: > [EMAIL PROTECTED] wrote: >> From a table, I want to get the cells for then only choose some of them. >> >> >> >> WY >> Wyo. >> >> ... >> >> >> Using: >> >> for row in table('tr'): print row.contents >> >>['\n', WY, '\n', Wyo., '\n'] >>[...] >> >>

[Tutor] BeautifulSoup - getting cells without new line characters

2006-03-31 Thread jonasmg
From a table, I want to get the cells for then only choose some of them. WY Wyo. ... Using: for row in table('tr'): print row.contents ['\n', WY, '\n', Wyo., '\n'] [...] I get a new line character between each cell. Is possible get them without those '\n'? Thanks in advance

Re: [Tutor] BeautifulSoup - deleting tags

2006-03-28 Thread jonasmg
Kent Johnson writes: > [EMAIL PROTECTED] wrote: >> Is possible deleting all tags from a text and how? >> >> i.e.: >> >> s='foo bar; >> foo2 > title="...">bar2' >> >> so, I would get only: foo bar, foo2, bar2 > > How about this? > > In [1]: import BeautifulSoup > > In [2]: s=Beautifu

[Tutor] BeautifulSoup - deleting tags

2006-03-28 Thread jonasmg
Is possible deleting all tags from a text and how? i.e.: qwe='foo bar; foo2 bar2' so, I would get only: foo bar, foo2, bar2 Thanks in advance! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] using BeautifulSoup

2006-03-28 Thread jonasmg
Kent Johnson writes: > [EMAIL PROTECTED] wrote: >> anchor.findNext('code') fails: >> >> anchor = soup.fetch('a', {'href': '/wiki/List_of_country_calling_codes'}) >> print anchor >> >> [Calling code] >> >> anchor.findNext('code') >> [] > > are you sure that's what you got? Looks like a

Re: [Tutor] using BeautifulSoup

2006-03-27 Thread jonasmg
[EMAIL PROTECTED] writes: >>jonasmg at softhome.net wrote: >>> Hi! >>> >>> I'm trying to use BeautifulSoup for get data from a table (on right) from: >>> http://en.wikipedia.org/wiki/United_states >>> >>&g

Re: [Tutor] using BeautifulSoup

2006-03-27 Thread jonasmg
>jonasmg at softhome.net 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 &

Re: [Tutor] compilte python to an executable file.

2006-03-27 Thread jonasmg
>jonasmg at softhome.net 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 '+

[Tutor] using BeautifulSoup

2006-03-27 Thread jonasmg
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

[Tutor] matching a file

2005-12-28 Thread jonasmg
Hi! I would to working with some files. But I have to using a regular expression with one of them: for file in [glob.glob('/etc/env.d/[0-9]*foo'), '/etc/bar']: glob returns a list so i'm supposed that i would that convert it into a string. Is it correct? Thanks for your help ___