Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68769
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.020 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'root': 0.05; 'element': 0.07; 'subject:help': 0.08; '22,': 0.09; '"item"': 0.16; 'at.': 0.16; 'element.': 0.16; 'iterating': 0.16; 'iteration,': 0.16; 'pulling': 0.16; 'variable.': 0.16; 'subject:python': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'trying': 0.19; '(the': 0.22; 'replace': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'changing': 0.37; 'searching': 0.37; 'two': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'bad': 0.39; 'to:addr:python.org': 0.39; 'affect': 0.61; 'entire': 0.61; "you're": 0.61; 'first': 0.61; 'refer': 0.63; 'different': 0.65; 'here': 0.66; 'mar': 0.68; 'results': 0.69; 'below.': 0.71 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=CkFijpnyAiykb6slMXgHeqKTjkpbh6eK6nsX+7Ld2QA=; b=db7WZsy5gp+nEmLNIXkrDxEci2/2I+dmXEZVQLJK9Br1w0ZYUqnTOVboU8bOnvXwne Jf1DxawwKrVzmibiJorRePeFpYM625okQbOGpJMR5ysw06WSw+/w1Gh4G5si7VuzCNyA hkZUEYNiKdcH8KJX8wwyJLofr5+AolANmRIM+6Gv20swcpwR4o7RlnM2Y+i7yLqNXCRR WdaERMCbutPi1d1F6+HQ0hyQzPZAIF1vDMYvVkbWu1P+2kAfR/uTIc2UegS0ssp2G9GK 4udr37PV9VjP8QI/EWE4Mvij9GEQWXB64Xun3EWqrZjZ88gfh36gYMdTmkPhJwJIypUY pkzg== |
| X-Received | by 10.66.20.10 with SMTP id j10mr61306169pae.11.1395489694242; Sat, 22 Mar 2014 05:01:34 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <84eb4c69-d43d-4777-8a99-34eed9be73d6@googlegroups.com> |
| References | <84eb4c69-d43d-4777-8a99-34eed9be73d6@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Sat, 22 Mar 2014 06:00:47 -0600 |
| Subject | Re: help with for loop----python 2.7.2 |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8394.1395489716.18130.python-list@python.org> (permalink) |
| Lines | 20 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1395489716 news.xs4all.nl 2921 [2001:888:2000:d::a6]:45066 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:68769 |
Show key headers only | View raw
On Sat, Mar 22, 2014 at 5:21 AM, <teddybubu@gmail.com> wrote:
> I am trying to get all the element data from the rss below.
> The only thing I am pulling is the first element.
> I don't understand why the for loop does not go through the entire rss.
> Here is my code....
[SNIP]
> for item in soup.find_all('item'):
> #for item in soup:
> title = soup.find('title').text
> link = soup.find('link').text
> item = soup.find('item').text
The three find method calls in the for loop are searching from the
document root (the "soup" variable), not from the item you're
currently iterating at. Try changing these to calls of item.find. And
note that calling one of the results "item" will replace the loop
variable. That won't affect the iteration, but it's bad practice to
refer to two different things by the same local name.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
help with for loop----python 2.7.2 teddybubu@gmail.com - 2014-03-22 04:21 -0700
Re: help with for loop----python 2.7.2 Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-22 06:00 -0600
Re: help with for loop----python 2.7.2 tad na <teddybubu@gmail.com> - 2014-03-23 10:29 -0700
Re: help with for loop----python 2.7.2 tad na <teddybubu@gmail.com> - 2014-03-23 10:30 -0700
Re: help with for loop----python 2.7.2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-23 17:40 +0000
Re: help with for loop----python 2.7.2 tad na <teddybubu@gmail.com> - 2014-03-23 10:49 -0700
Re: help with for loop----python 2.7.2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-23 18:43 +0000
Re: help with for loop----python 2.7.2 Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-23 11:49 -0600
Re: help with for loop----python 2.7.2 tad na <teddybubu@gmail.com> - 2014-03-23 14:51 -0700
Re: help with for loop----python 2.7.2 Ian Kelly <ian.g.kelly@gmail.com> - 2014-03-23 16:44 -0600
Re: help with for loop----python 2.7.2 Ben Finney <ben+python@benfinney.id.au> - 2014-03-24 09:39 +1100
csiph-web