Get the title of a given URL.

This technical problem deals with scraping the title from a given URL. An example input and output is provided.

Problem

Given a URL, return the title of the page.
Example input:
"https://www.google.com"
Example output:
"Google"

Solution

This solution is in Python. Our A.I. can create solutions in multiple languages.
by kayakane
import requests
from bs4 import BeautifulSoup

def get_title(url):
    r = requests.get(url)
    soup = BeautifulSoup(r.text, 'html.parser')
    return soup.title.string

print(get_title("https://www.google.com"))

A.I. Evaluation of the Solution

This solution correctly imports the necessary libraries and defines the get_title function. This function takes in a url and returns the title of the page using BeautifulSoup. This is a good solution.

Evaluated at: 2022-11-11 08:16:02