'Extracting contents of html into BeautifulSoup if search for script ID is a success
My html is below:
<html>
<body>
<div> ... </div>
<script id="1" ...> </script>
</body>
</html>
<html>
<body>
<div> ... </div>
<script id="2" ...> </script>
</body>
<html>
With BeautifulSoup, I am able to pull the script with id like so
soup.find("script", {"id": "1"})
My goal is to, however, extract the entire html that contains the script with id = "1". Is that possible?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|