Friday, 19 June 2009

TIP - Get page title with BeautifulSoup

Using BeautifulSoup, it is possible to access different elements of webpages from within Python. This example shows how to get the HTML pages title tag:-

import urllib
import BeautifulSoup

soup
= BeautifulSoup.BeautifulSoup(urllib.urlopen("https://www.google.com"))
print soup.title.string

No comments:

Post a Comment