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: