import requests
from bs4 import BeautifulSoup
pre={"User-agent":"Mozilla.5.0"}
url='https://lishi.tianqi.com/shanghai/202109.html'
re=requests.get(url, headers=pre)
re.encoding='utf-8'
sp=BeautifulSoup(re.text,'html.parser')
print(sp.title.string)

#Another method
#title=str(sp.select('title'))
#print(title[8:-9])
print("\n")
r=requests.get('https://www.taobao.com/')
#打印字节流数据
s=BeautifulSoup(r.text,'html.parser')
print(s.title.string)
# print(r.content.decode('utf-8'))  #转码
#print(r.text)  #打印文本数据
