I want to call a Beautiful Soup attributes (eg. class_, href, id) from a variable to use it in functions such as this one:
script
from b
You can pass a dictionary instead:
from bs4 import BeautifulSoup data='xxx yyy zzz' soup = BeautifulSoup(data, "html.parser") def removeAttrib(soup, tag, argdict): for x in soup.findAll(tag, argdict): x.decompose() removeAttrib(soup, "p", {"class": "story"})
xxx
yyy
zzz