Answers for "bs4 find all href with class"

4

get href bs4

from BeautifulSoup import BeautifulSoup

html = '''<a href="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']
Posted by: Guest on May-12-2020

Python Answers by Framework

Browse Popular Code Answers by Language