Get page title from URL

This technical problem deals with retrieving the page title from a URL using Python. The given URL is http://www.google.com and the expected output is simply "Google".

Problem

Write a Python script that takes a URL as input and prints out the page title.
Input:
http://www.google.com
Output:
Google

Solution

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

url = raw_input("Enter a website to extract the URL's from: ")

r = urllib2.urlopen(url).read()
soup = BeautifulSoup(r)

print(soup.title.string)

A.I. Evaluation of the Solution

This solution correctly imports the necessary libraries and prompts the user for input. It then uses the urllib2 library to read the contents of the website and BeautifulSoup to parse the HTML. Finally, it prints out the title of the page. This is a complete solution that correctly solves the problem.

Evaluated at: 2022-11-25 10:16:53