Replaces the content of soup that matches the css selector with the given replace content.
(
self, soup: BeautifulSoup, css_sel: str, replace: BeautifulSoup
)
| 93 | self.persistent = updated[self.OPT_MAP_PERSISTENT] |
| 94 | |
| 95 | def replace( |
| 96 | self, soup: BeautifulSoup, css_sel: str, replace: BeautifulSoup |
| 97 | ) -> None: |
| 98 | """Replaces the content of soup that matches the css selector with the given replace content.""" |
| 99 | for content in soup.select(css_sel): |
| 100 | self.logger.debug(f'replace "{content}" with "{replace}"') |
| 101 | content.replace_with(copy.copy(replace)) |
| 102 | |
| 103 | def apply_template( |
| 104 | self, soup: BeautifulSoup, template: dict[str, BeautifulSoup] |