Python BeautifulSoup: Find tag(s) directly beneath other tag(s) in a given html document
Write a Python program to find tag(s) directly beneath other tag(s) in a given html document.
Sample Solution:
Python Code:
Sample Output:
Beneath directly head tag: [<title>An example of HTML page</title>] Beneath directly p tag: [<a href="https://www.w3resource.com/html/HTML-tutorials.php">Learn HTML from w3resource.com</a>, <a href="https://www.w3resource.com/css/CSS-tutorials.php">Learn CSS from w3resource.com</a>]
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to find tag(s) beneath other tag(s) in a given html document.
Next: Write a Python program to find the siblings of tags in a given html document.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.