python BeautifulSoup獲取網頁正文


通過BeautifulSoup庫的get_text方法找到網頁的正文:

#!/usr/bin/env python
#coding=utf-8

#HTML找出正文

import requests
from bs4 import BeautifulSoup

url='http://www.baidu.com'
html=requests.get(url)

soup=BeautifulSoup(html.text)
print soup.get_text()

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章