BeautifulSoup: rel attribute Example
Syntax
el['rel']
rel attribute Example
from bs4 import BeautifulSoup
# Html source
html_source = '''
<a rel="nofollow" href="http://www.pyonlycode.com/">Pyonlycode</a>
'''
# Parsing
soup = BeautifulSoup(html_source, 'html.parser')
# get <a> element
el = soup.a
# Print rel attribute
print(el['rel'])
Output:
['nofollow']