用requests库和BeautifulSoup4库爬取新闻列表
import requests from bs4 import BeautifulSoup jq='http://news.gzcc.cn/html/2017/xiaoyuanxinwen_0926/8262.html' res = requests.get(jq) res.encoding='gb2312' soup = BeautifulSoup(res.text,'html.parser') for news in soup.select('li'): if len(news.select('a'))>0: title=news.select('a')[0].text url=news.select('a')[0]['href'] #time=news.select('span')[0].contents[0].text #print(time,title,url) print(title,url)