Check from within some content

6 views
Skip to first unread message

Proxy

unread,
Dec 6, 2009, 6:46:21 PM12/6/09
to beautifulsoup
I am trying to read the content of some html that is inside a table,
and just display some of the lines, for example the table contains 20
lines, and I just want 7 from the middle. I could do this one by one
but that wouldn't be efficient or even recommended and so far I don't
know how to limit the search between (for example) values 3 and up to
10 of the list...so far I have:

complejo = soup.html.body.findAll(width="695", limit=14)
for p in complejo:
p = pelisVIP.find('a')
clasif = p.find(attrs={"class" : "texto"})
horas = p.findAll(text=re.compile("pm$"))
if p.string != None:
print nombre[1]
print p.string, clasif.string
print horas
print "\n"
print
"========================================================="

the thing is I don't really want the 14 that are printed I just want
some of the ones in the middle =/ no idea how to do that... any help
please?

Aaron DeVore

unread,
Dec 6, 2009, 7:12:28 PM12/6/09
to beauti...@googlegroups.com
You should be able to do slicing with the list.

complejo = complejo[7:]

By the way, are you sure you want this line?
p = pelisVIP.find('a')

It looks like it would overwrite the p from the for loop.

-Aaron
> --
>
> You received this message because you are subscribed to the Google Groups "beautifulsoup" group.
> To post to this group, send email to beauti...@googlegroups.com.
> To unsubscribe from this group, send email to beautifulsou...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/beautifulsoup?hl=en.
>
>
>

Proxy

unread,
Dec 6, 2009, 7:58:58 PM12/6/09
to beautifulsoup
would you mind explaining me a bit how the "slicing" works?? and where
should I place it =)?

On Dec 6, 5:12 pm, Aaron DeVore <aaron.dev...@gmail.com> wrote:
> You should be able to do slicing with the list.
>
> complejo = complejo[7:]
>
> By the way, are you sure you want this line?
> p = pelisVIP.find('a')
>
> It looks like it would overwrite the p from the for loop.
>
> -Aaron
>

Proxy

unread,
Dec 6, 2009, 7:37:54 PM12/6/09
to beautifulsoup
yes actually the p = pelisVIP was an error I took out that =D, but
would you mind explaining me a bit more (or just telling me what to
google for) what is the "slicing" and how it works??

Thanks

On Dec 6, 5:12 pm, Aaron DeVore <aaron.dev...@gmail.com> wrote:
> You should be able to do slicing with the list.
>
> complejo = complejo[7:]
>
> By the way, are you sure you want this line?
> p = pelisVIP.find('a')
>
> It looks like it would overwrite the p from the for loop.
>
> -Aaron
>

Aaron DeVore

unread,
Dec 6, 2009, 8:29:12 PM12/6/09
to beauti...@googlegroups.com
It's just simple list slicing. The Python documentation (python.org)
should have a section on it.

-Aaron
Reply all
Reply to author
Forward
0 new messages