#把網頁http://acupun.byethost7.com/phpexample/exp16-6-1.html',存檔成web1.htm #用網路爬蟲,讀取這個web1.html的網頁標題 # = "http://acupun.byethost7.com/phpexample/exp16-6-1.html" from bs4 import BeautifulSoup as soup #讀取網頁文字檔 f1 = open('web1.html','r',encoding='utf-8') txt = f1.read() print(txt) #轉成網頁 htm = soup(txt,'html.parser') print(htm) #讀取網頁標題 print(htm.title) print(htm.title.prettify()) #標題名稱:htm.title.string print(htm.title.string)