BeautifulSoup and prettify() function

Viewed 24488

To parse html codes of a website, I decided to use BeautifulSoup class and prettify() method. I wrote the code below.

import requests
import bs4

response = requests.get("https://www.doviz.com")
soup = bs4.BeautifulSoup(response.content, "html.parser")
print(soup.prettify())

When I execute this code on Mac terminal, indentation of the codes are not set. On the other hand, If I execute this code on windows cmd or PyCharm, all codes are set.

Do you know the reason for this ?

1 Answers

try this code:

import requests
from bs4 import BeautifulSoup
response = requests.get("https://www.doviz.com")
soup = BeautifulSoup(response.text, "html.parser")
print(soup.prettify())
Related