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
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
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.
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
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(
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.
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
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'
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']
>>[...]
>>
>>
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
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
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
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
[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
>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 &
>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 '+
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
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
___
18 matches
Mail list logo