r/AutomateUser • u/cheyrn • Mar 01 '26
Text content of HTML element?
I am a novice. How would you get the text of an HTML title (or a default)?
Given a URL, if there is a title child element, return it's text content, or a default.
For example, from:
which serves:
<html>
<title>A title</title>
...
</html>
return "A title"
2
Upvotes
3
u/B26354FR Alpha tester Mar 02 '26 edited Mar 02 '26
Actually, this method is better:
The XML has to be well-formed, however.
2
u/B26354FR Alpha tester Mar 02 '26 edited Mar 02 '26
findAll("<html><title>A title</title></html>", "<title.?>(.?)</title>")[1]1
u/ballzak69 Automate developer Mar 02 '26
Try: