from BeautifulSoup import BeautifulSoup html = '''next later''' soup = BeautifulSoup(html) for a in soup.find_all('a', href=True): print "Found the URL:", a['href']
Here is what the above code is Doing:
1. We’re creating a BeautifulSoup object from the HTML string.
2. We’re using the find_all method to find all the tags in the HTML.
3. We’re looping through each of the tags and printing out the value of the href attribute.