Python Forum
find chars after chars in 'pre' tag
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
find chars after chars in 'pre' tag
#2
You need to convert it from a BeautifulSoup object to a string. There isnt much more BeautifulSoup can do after acquiring the pre tag content. Most of the time there are more nested tags to narrow the needle search. You would get the text as a string via
print(y.text)
then you just have to use python string methods to split it out
print(y.text.split())
Output:
['Text', 'in', 'a', 'pre', 'element', 'is', 'displayed', 'in', 'a', 'fixed-width', 'XYZ57', 'ABCD', '141800', 'font,', 'and', 'it', 'preserves', 'both', 'spaces', 'and', 'line', 'breaks']
if you looking for ABCD...if its always the 12th element, you can grab it that way. Is ABCD always static? Or does that change too? What are a few different outcomes to get the proper target?
Recommended Tutorials:
Reply


Messages In This Thread
find chars after chars in 'pre' tag - by Fran_3 - Aug-17-2017, 11:18 PM
RE: find chars after chars in 'pre' tag - by metulburr - Aug-17-2017, 11:38 PM
RE: find chars after chars in 'pre' tag - by Fran_3 - Aug-19-2017, 04:27 PM
RE: find chars after chars in 'pre' tag - by Fran_3 - Aug-19-2017, 08:30 PM
RE: find chars after chars in 'pre' tag - by Fran_3 - Aug-20-2017, 02:56 PM
RE: find chars after chars in 'pre' tag - by Fran_3 - Aug-22-2017, 11:44 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020