Python BeautifulSoup: Print the names of all HTML tags of a given web page going through the document tree
BeautifulSoup: Exercise-13 with Solution
Write a Python program to print the names of all HTML tags of a given web page going through the document tree.
import requests from bs4 import BeautifulSoup url = 'https://www.python.org/' reqs = requests.get(url) soup = BeautifulSoup(reqs.text, 'lxml') print("\nNames of all HTML tags (https://www.python.org):\n") for child in soup.recursiveChildGenerator(): if child.name: print(child.name)
Names of all HTML tags (https://www.python.org): html head meta meta link meta meta meta meta meta meta meta meta meta meta script link link link link link link link link meta meta meta title .......... script script script script script
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
Python: Tips of the Day
name = ["Owen", "Eddie"] print(" ".join(name))
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook