Coding Quiz
This coding quiz involves writing a program to extract h1 tags
(main titles) from a web page using the selenium
library.
Complete the solution
function in the code editor to extract the title of the web page from the given URL.
Coding Quiz Template
from selenium import webdriver
def solution(url):
# Create Chrome WebDriver
driver = webdriver.Chrome()
# Write your code here
Hints
-
You can open the web page using
driver.get(url)
. -
You can extract the title of the web page using
page_title = driver.title
. -
You can close the web driver using the
driver.quit()
function.
Click the view solution button at the bottom right for an example of the function.
Based on what you've learned so far, write a program to extract the title from a web page and check if it passes the test.
Input and Output Examples
Example 1
-
Input: "https://www.python.org"
-
Output: "Welcome to Python.org"
Example 2
-
Input: "https://example.com"
-
Output: "Example Domain"
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.