BeautifulSoup getting href [duplicate]
You can use find_all in the following way to find every a element that has an href attribute, and print each one: from BeautifulSoup import BeautifulSoup html=””‘<a href=”https://stackoverflow.com/questions/5815747/some_url”>next</a> <span class=”class”><a href=”another_url”>later</a></span>”’ soup = BeautifulSoup(html) for a in soup.find_all(‘a’, href=True): print “Found the URL:”, a[‘href’] The output would be: Found the URL: some_url Found the URL: … Read more