samedi 8 mars 2014

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




> 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





Aucun commentaire:

Enregistrer un commentaire