Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Strip some html codes out
-
Here is my script:
from bs4 import BeautifulSoup as soup from urllib.request import urlopen as uReq page_url = ('http://fcs002.xreflector.net/_user.html') uClient = uReq(page_url) page_soup = soup(uClient.read(), "html.parser") uClient.close lh = page_soup.findAll("td") print (lh[10])
It prints out:
<td><div align="left">WW6E </div></td>how can I end up with just the WW6E ?
Thanks,
Michael -
print(lh[10].text.strip())
No space between print and ( because print() is a function just like every other function.
-
I think he wants to remove html tags, like with innerText of webView.eval_js
-
>>> from bs4 import BeautifulSoup >>> soup = BeautifulSoup('<td><div align="left">WW6E </div></td>') >>> soup.text.strip() 'WW6E'
BeautifulSoup is going to make JavaScript look sloppy.
-
@ccc thank you - that works perfectly
-
print(lh[10].text.strip())
works perfectly- thank you!