INNER CODE UNIT · Python
remove_blacklisted_attributes
handrew/browserpilot · browserpilot/agents/gpt_selenium_agent.py:215
def remove_blacklisted_attributes(tag, blacklisted_attributes):
for attr in tag.attrs.copy():
for pattern in blacklisted_attributes:
if re.match(pattern, attr):
del tag[attr]
for tag in soup.find_all(True):
remove_blacklisted_attributes(tag, blacklisted_attributes)
return soup
def __get_html_elements_for_llm(self):
"""Returns list of BeautifulSoup elements for use in GPT Index.
First removes blacklisted elements and attributes, then removes any
children of elements. Finally, removes any elements with no attrs.
"""
soup = self._remove_blacklisted_elements_and_attributes()