Reptile diary - based HTML formatting and coding bs4 library

HTML-based formatting and coding bs4 library

import requests
from bs4 import BeautifulSoup
r=requests.get('https://python123.io/ws/demo.html')
demo=r.text
soup = BeautifulSoup(demo,'html.parser')

print(soup.prettify())

Before we talking about the delicious soup, it already used once prettify method, and then there is no explaining to do, because I did not find myself, I do not know what it is, just know that after using that method, to crawling the html could have been a group, become a long one, and looks a lot clearer.

As for coding, prettify encoding format is utf8, as long as there have been utf8, basically have nothing to worry about up. Even if the content is Chinese, he also can print out.

Guess you like

Origin www.cnblogs.com/chanyuli/p/11403593.html