爬虫

安装 request

beautifulsoup4安装

import requests
requests
import bs4
from bs4 import BeautifulSoup
bs4
url = 'http://news.gzcc.cn/html/2019/xiaoyuanxinwen_0328/11086.html'
res = requests.get(url)
type(res)
res.text
res.status_code
soupn = BeautifulSoup(res.text,'html.parser')
soupn
soupn.title.text
soupn.select('.show-info')[0].text.split()[0].split(':')[1]
soupn.select('.show-content')[0].text
soupn.select('.show-info')[0].text.split()[2].split(':')[1]
原文地址:https://www.cnblogs.com/ShaoJingWen/p/10621465.html