Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68045 > unrolled thread

Re: How to extract contents of inner text of html tag?

Started byJason Friedman <jsf80238@gmail.com>
First post2014-03-08 09:55 -0700
Last post2014-03-08 09:55 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to extract contents of inner text of html tag? Jason Friedman <jsf80238@gmail.com> - 2014-03-08 09:55 -0700

#68045 — Re: How to extract contents of inner text of html tag?

FromJason Friedman <jsf80238@gmail.com>
Date2014-03-08 09:55 -0700
SubjectRe: How to extract contents of inner text of html tag?
Message-ID<mailman.7933.1394297744.18130.python-list@python.org>
> for line in all_kbd:
>    if line.string == None:

I modified your code slightly:
for line in all_kbd:
    print(line)
    sys.exit()
    if line.string == None:

Running the new script yields:
$ python shibly.py
<kbd class="command">
    cp -v --remove-destination /usr/share/zoneinfo/
    <em class="replaceable"><code><xxx></xxx></code></em>
       \
    /etc/localtime
</kbd>

Meaning that
all_kbd=soup.find_all('kbd')

yields only a single string, not multiple strings as I'm guessing you expected.

You might also consider running your program as:

python -m pdb your_program.py

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web