Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get title with beautifulsoup

# To get the title from BeautifulSoup
def getTitle(url):
    try:
        html=urlopen(url)
    except HTTPError as e:
        return None
    try:
        bs=BeautifulSoup(html.read(), 'html.parser')
        title=bs.body.h1 
    except AttributeError as e:
        return None 
    return title
 
PREVIOUS NEXT
Tagged: #title #beautifulsoup
ADD COMMENT
Topic
Name
1+9 =