I ran the following code:
url_req = "https://en.wikipedia.org/wiki/A._P._J._Abdul_Kalam"
response = requests.get(url=url_req,verify=True)
soup = BeautifulSoup(response.text, "lxml")
How can I save this soup object as an XML file to disk?
You can write the output of .prettify() to a file:
with open('file.xml', 'w') as f:
f.write(soup.prettify())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With