Examples given in the Python BeautifulSoup 4 Documentation
Question: I am learning the BeautifulSoup 4 Documentation, and want to exercise the
examples given.

I am trying the examples however it’s not successful. An example below.

Seems I am not putting it in a right way, and problem lies in the ‘url’. Could
some kindness showing me the right way to put them? Thanks.

    
    
    from bs4 import BeautifulSoup
    import re
    import urllib2
    
    
    url = '<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>'
    
    page = urllib2.urlopen(url)
    soup = BeautifulSoup(page.read())
    
    Learning = soup.find_all("a", class_="sister")
    
    print Learning
    


Answer: `'<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>'` is
not an url.

The code contains html; You don't need to use `urllib2.urlopen`.

    
    
    from bs4 import BeautifulSoup
    
    page = '<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>'
    soup = BeautifulSoup(page)
    Learning = soup.find_all("a", class_="sister")
    print Learning
    

